开发者

How to get a GNUmakefile to recognize CFLAGS option for -std=c99 or -std=gnu99?

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 'ma开发者_StackOverflow中文版ke 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


ADDITIONAL_FLAGS += -std=gnu99 worked for me (inspired by https://github.com/maddox/regexkit/blob/master/GNUstep/GNUmakefile


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.


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?


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜