【发布时间】:2017-06-26 17:11:49
【问题描述】:
下面的“Objective-C 编程(第 6 版)显示了这个Hello World
#import <Foundation/Foundation.h>
int main(void)
{
@autoreleasepool
{
NSLog(@"Programming is fun!");
}
return 0;
}
当我尝试使用 GNUStep makefile 编译程序时
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = Hello
Hello_OBJC_FILES = hello.m
include $(GNUSTEP_MAKEFILES)/tool.make
我收到诸如
之类的错误hello.m: In function 'main':
hello.m:5:2: error: stray '@' in program
hello.m:5:3: error: 'autoreleasepool' undeclared (first use in this function)
hello.m:5:3: note: each undeclared identifier is reported only once for each function it appears in
hello.m:5:19: error: expected ';' before '{' token
hello.m:9:1: warning: control reaches end of non-void function [-Wreturn-type]
make[3]: *** [obj/Hello.obj/hello.m.o] Error 1
make[2]: *** [internal-tool-all_] Error 2
make[1]: *** [Hello.all.tool.variables] Error 2
make: *** [internal-all] Error 2
我做错了吗?我在程序中看不到任何错误,我不确定为什么 makefile 不起作用。
我应该添加我在 Windows 10 上运行
【问题讨论】:
-
我不知道答案,但我想知道 .m 类型是否无法识别。错误消息中的“hello.m.o”看起来很可疑。这个 (gnustep.org/resources/documentation/Developer/Base/…) 有一个示例 F.1.1,它显示了告诉
make如何处理 .m 后缀的行。 -
奇怪的是,这个 (gnustep.org/resources/documentation/Developer/Base/…) 提供了一个可以使用给定工具成功编译的 Objective-C 程序(在第 1.5 节中)。
-
gcc 现在支持
@autoreleasepool吗?好一阵子都没有。 stackoverflow.com/q/22275252/603977 stackoverflow.com/q/10468901/603977 你的日志让它看起来仍然是真的。
标签: objective-c makefile gnustep