如何让 GNUmakefile 识别 -std=c99 或 -std=gnu99 的 CFLAGS 选项?
我正在尝试使用编译器选项 c99 或 gnu99 编译 GNUstep 程序,但它没有被识别...这是我的 makefile:
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = triangular
triangular_C_FLAGS = -std=gnu99
triangular_HEADERS =
triangular_OBJC_FILES = main.m
triangular_RESOURCE_FILES =
include $(GNUSTEP_MAKEFILES)/tool.make
任何人都可以指出我正确的方向或让我知道我在做什么错误的?
这是 make 的输出:
This is gnustep-make 2.6.0. Type 'make print-gnustep-make-help' for help.
Making all for tool triangular...
Compiling file main.m ...
main.m: In function 'main':
main.m:18:3: error: 'for' loop initial declarations are only allowed in C99 mode
main.m:18:3: note: use option -std=c99 or -std=gnu99 to compile your code
make[3]: *** [obj/triangular.obj/main.m.o] Error 1
make[2]: *** [internal-tool-all_] Error 2
make[1]: *** [triangular.all.tool.variables] Error 2
make: *** [internal-all] Error 2
I'm trying to compile a GNUstep program with the compiler option either c99 or gnu99, but it isn't being recognized ... here is my makefile:
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = triangular
triangular_C_FLAGS = -std=gnu99
triangular_HEADERS =
triangular_OBJC_FILES = main.m
triangular_RESOURCE_FILES =
include $(GNUSTEP_MAKEFILES)/tool.make
Can anyone point me in the right direction or let me know what I'm doing wrong?
Here is the output from make:
This is gnustep-make 2.6.0. Type 'make print-gnustep-make-help' for help.
Making all for tool triangular...
Compiling file main.m ...
main.m: In function 'main':
main.m:18:3: error: 'for' loop initial declarations are only allowed in C99 mode
main.m:18:3: note: use option -std=c99 or -std=gnu99 to compile your code
make[3]: *** [obj/triangular.obj/main.m.o] Error 1
make[2]: *** [internal-tool-all_] Error 2
make[1]: *** [triangular.all.tool.variables] Error 2
make: *** [internal-all] Error 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
ADDITIONAL_FLAGS += -std=gnu99
为我工作
(灵感来自 https://github.com/maddox/regexkit/blob/master/ GNUstep/GNUmakefile
ADDITIONAL_FLAGS += -std=gnu99
worked for me
(inspired by https://github.com/maddox/regexkit/blob/master/GNUstep/GNUmakefile
乍一看,在不知道所包含的 makefile 内容的情况下,这看起来像是 automake 的输入,它将变量转换为正确的规则。你如何运行你的makefile?您只是运行
make
或automake makefile.am
还是其他东西?可以尝试的一件事就是将该行添加
到您的 makefile 中。
At first glance and without knowing the contents of the included makefiles this looks like input for
automake
, which converts the variables into proper rules. How are you running your makefile? Are you just runningmake
orautomake makefile.am
or something else?One thing to try is to just add the line
to your makefile.
我对 GNUstep 一无所知,但是 文档 似乎表明您应该使用 triangular_CFLAGS(C 和 FLAGS 之间不带下划线)。
此外,我对 ObjC 的了解更少,但我想知道你是否不应该使用
triangle_OBJCFLAGS
来代替?I don't know anything about GNUstep, but the documentation seems to indicate that you should use
triangular_CFLAGS
(without the underscore between C and FLAGS).Besides, I know even less about ObjC, but I'm wondering if you shouldn't use
triangular_OBJCFLAGS
instead?另一个远景:(
这些 makefile 似乎是递归的。)如果这不起作用,您必须找到尝试构建
main.o
的规则。Another long shot:
(These makefiles seem to be recursing.) If that doesn't work, you'll have to find the rule that is attempting to build
main.o
.我在我的项目中遇到了类似的问题,并且使用 @eriktous 建议的 OBJCFLAGS 变量对我有用。因此,在您的项目中,尝试以下操作:
I faced a similar problem in my project, and using the OBJCFLAGS variable suggested by @eriktous worked for me. So, in your project, try this: