如何让 GNUmakefile 识别 -std=c99 或 -std=gnu99 的 CFLAGS 选项?

发布于 2024-11-17 14:22:29 字数 895 浏览 4 评论 0原文

我正在尝试使用编译器选项 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

倦话 2024-11-24 14:22:29

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

苍景流年 2024-11-24 14:22:29

乍一看,在不知道所包含的 makefile 内容的情况下,这看起来像是 automake 的输入,它将变量转换为正确的规则。你如何运行你的makefile?您只是运行 makeautomake makefile.am 还是其他东西?

可以尝试的一件事就是将该行添加

CFLAGS+=-std=gnu99

到您的 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 running make or automake makefile.am or something else?

One thing to try is to just add the line

CFLAGS+=-std=gnu99

to your makefile.

清醇 2024-11-24 14:22:29

我对 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?

心作怪 2024-11-24 14:22:29

另一个远景:(

export triangular_C_FLAGS = -std=gnu99

这些 makefile 似乎是递归的。)如果这不起作用,您必须找到尝试构建 main.o 的规则。

Another long shot:

export triangular_C_FLAGS = -std=gnu99

(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.

风铃鹿 2024-11-24 14:22:29

我在我的项目中遇到了类似的问题,并且使用 @eriktous 建议的 OBJCFLAGS 变量对我有用。因此,在您的项目中,尝试以下操作:

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = triangular
triangular_OBJCFLAGS = -std=c99
triangular_HEADERS =
triangular_OBJC_FILES = main.m
triangular_RESOURCE_FILES =

include $(GNUSTEP_MAKEFILES)/tool.make

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:

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = triangular
triangular_OBJCFLAGS = -std=c99
triangular_HEADERS =
triangular_OBJC_FILES = main.m
triangular_RESOURCE_FILES =

include $(GNUSTEP_MAKEFILES)/tool.make
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文