我在mac机器上使用OS 10.9.我想知道我正在使用的gcc版本.所以我尝试gcc --version了终端,结果如下:
$ gcc --version
Configured with: --prefix=/Applications/Xcode5-DP.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode5-DP.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.1.58) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Run Code Online (Sandbox Code Playgroud)
在输出中,没有与gcc相关的细节,但clang就在那里.我很困惑gcc命令是否执行clang或gcc(gnu).
我收到与err_sys()此代码相关的错误:
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main()
{
int sockfd;
if ((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)
err_sys("can't create socket");
close(sockfd);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到链接器错误:
/tmp/cciuUVhz.o: In function `main':
getsockopt.c:(.text+0x38): undefined reference to `err_sys'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
功能在哪里err_sys()定义?
有人可以提供从goroutine返回的澄清值.来自goroutine的返回值是否存储在桩上.
例如:
// function getNumber returns the "int i" and we can't use this returned value
// because this function is invoked as goroutine.
// We know that, to communicate between main and goroutine one could
// use the channel ( chan <- i), but I am interested to know about
// the use of return i in goroutine. Is it possible to get/ use this
// returned value.
func getNumber(i int) int {
return i
}
func main() { …Run Code Online (Sandbox Code Playgroud) 我是我的UIView课的子类.Xcode(我使用的是4.6.3)自动生成的代码说,
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
Run Code Online (Sandbox Code Playgroud)
它在我的脑海中提出了几个问题:
1)为什么空的实现drawRect:会在动画期间导致不良性能.
2)我什么时候应该实施drawRect:.
3)如果我正在实施,drawRect:那么应采取什么措施作为最佳实践的预防措施.
我正在尝试编写一个函数Map,以便它可以处理所有类型的数组.
// Interface to specify generic type of array.
type Iterable interface {
}
func main() {
list_1 := []int{1, 2, 3, 4}
list_2 := []uint8{'a', 'b', 'c', 'd'}
Map(list_1)
Map(list_2)
}
// This function prints the every element for
// all []types of array.
func Map(list Iterable) {
for _, value := range list {
fmt.Print(value)
}
}
Run Code Online (Sandbox Code Playgroud)
但它会抛出编译时错误.
19: cannot range over list (type Iterable)
Run Code Online (Sandbox Code Playgroud)
错误是正确的,因为range需要数组,指向数组,切片,字符串,映射或通道的指针允许接收操作,此处类型为Iterable.我认为我面临的问题是,将参数类型转换Iterable为数组类型.请建议,我如何使用我的函数来处理通用数组.
我正在关注以下博客来配置我的golang环境(OS-X机器):
http://webapp.org.ua/dev/intellij-idea-and-go-plugin/
但是,每当我尝试添加go sdk(安装在/ usr/local/go)时,它就会显示为SDK的空白选择.
如果我错过了什么,请建议我.
我是Iphone编程的初学者.我正在尝试编译(ubuntu).
#import <Foundation/Foundation.h>
int main (void)
{
NSLog (@"Executing");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我编译了它但得到了跟随错误
subhash@subhash-Lenovo-G570:~/grit/iphone/mac$ gcc -lgnustep-base -lpthread -lob
jc -lm -I/usr/local/include/GNUstep -I/usr/include/GNUstep -fconstant-string-cla
ss=NSConstantString hello.m -o hello
In file included from /usr/include/GNUstep/Foundation/NSClassDescription.h:30:0,
from /usr/include/GNUstep/Foundation/Foundation.h:50,
from hello.m:1:
/usr/include/GNUstep/Foundation/NSException.h:42:2: error: #error The current se
tting for native-objc-exceptions does not match that of gnustep-base ... please
correct this.
Run Code Online (Sandbox Code Playgroud)
我按照http://ubuntuforums.org/showthread.php?p=5593608作为参考.
我评论了NSException.h的#error指令,问题解决了.现在我收到了新的错误.
/tmp/ccQlI9wJ.o: In function `main':
hello.m:(.text+0x11): undefined reference to `NSLog'
/tmp/ccQlI9wJ.o: In function `__objc_gnu_init':
hello.m:(.text+0x2a): undefined reference to `__objc_exec_class'
/tmp/ccQlI9wJ.o:(.data+0x40): undefined reference …Run Code Online (Sandbox Code Playgroud) 我试图从下面的例子中提供谈话了解java8的尾递归.
@FunctionalInterface
public interface TailCall<T> {
TailCall<T> apply();
default boolean isComplete() {
return false;
}
default T result() {
throw new Error("not implemented");
}
default T get() {
return Stream.iterate(this, TailCall::apply).filter(TailCall::isComplete)
.findFirst().get().result();
}
}
Run Code Online (Sandbox Code Playgroud)
使用TailCall的实用程序类
public class TailCalls {
public static <T> TailCall<T> call(final TailCall<T> nextcall) {
return nextcall;
}
public static <T> TailCall<T> done(final T value) {
return new TailCall<T>() {
@Override
public boolean isComplete() {
return true;
}
@Override
public T result() {
return value;
} …Run Code Online (Sandbox Code Playgroud) 我正在关注编写我的网络应用程序的golang教程.我正在修改教程页面中的代码,以便我可以执行保存的页面作为go代码(类似于go playground).但是当我尝试使用os/exec包执行保存的go文件时,它会抛出以下错误.
exec:"go run testcode.go":在$ PATH中找不到可执行文件
以下是我修改过的代码:
// Structure to hold the Page
type Page struct {
Title string
Body []byte
Output []byte
}
// saving the page
func (p *Page) save() { // difference between func (p *Page) and func (p Page)
filename := p.Title + ".go"
ioutil.WriteFile(filename, p.Body, 0777)
}
// handle for the editing
func editHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[len("/edit/"):]
p, err := loadPage(title)
if err …Run Code Online (Sandbox Code Playgroud) 我想从 C 函数空间调用 go func,但程序抛出构建错误。
示例.go
package main
/*
#include "test.c"
*/
import "C"
import "fmt"
func Example() {
fmt.Println("this is go")
fmt.Println(C.GoString(C.myprint(C.CString("go!!"))))
}
// export receiveC (remove the extra space between // and export)
func receiveC(msg *C.char) {
fmt.Println(C.GoString(msg))
}
func main() {
Example()
}
Run Code Online (Sandbox Code Playgroud)
测试.c
#include <stdio.h>
extern void receiveC(char *msg);
char* myprint(char *msg) {
receiveC(msg); // calling the exported go function
return msg;
}
Run Code Online (Sandbox Code Playgroud)
当我执行命令来运行/构建(go build或go run example.go或go build example.go)程序时,它会抛出错误:
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用代码片段来理解要理解的collect方法IntStream.我试图结果Hashmap <string, Integer>.
IntStream.range(0, 4).collect(
HashMap::new,
result, t -> result.put("test", somearray.get(t)),
result -> result.putall()
);
Run Code Online (Sandbox Code Playgroud)
但汇编抱怨,can't find symbol variable result.
按我的理解,我需要传递(t, value) -> ...给accumulatore,但我无法理解编译问题,以及使用组合(第三个参数)的.
我试图使用这个SOAP客户端调用SOAP服务,但它不适合我.请帮我.如何使用Phonegap发送和接收XML SOAP?