1

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
  • 1
    You're not giving us enough information to go on. What happens when you try to run this? And what do `tool.make` and `common.make` look like? – Beta Jun 30 '11 at 03:49
  • I added the output from make. tool.make and common.make are big makefiles that are included with the GNUstep environment. – Arthur Vanderbilt Jun 30 '11 at 04:04
  • It's saying there's a problem in `main.m`, line 18. If the bug isn't obvious, try isolating that scrap of code in a `helloWorld` and compiling by hand, without Make. – Beta Jun 30 '11 at 05:26
  • @beta - line 18 of `main.m` will have something like `for (int i=0; i<10; ++i){`, which while illegal in c89 is valid in c99. The issue seems to be getting the `-std=gnu99` flag to the compiler. – Scott Wales Jun 30 '11 at 05:30

5 Answers5

3

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

inamist
  • 61
  • 1
  • 3
0

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
  • Could you explain a bit more? Maybe add a reference? – Shahbaz Jul 16 '12 at 12:07
  • I was attempting to solve a similar problem by applying the tip given by @eriktous in a previous reply to this question. That poster made a reference to the GNUstep [documentation](http://www.gnustep.org/resources/documentation/make_1.html#SEC16), which mentions the OBJCFLAGS variable. I have edited my original post to show the full makefile. – Lennart Månsson Jul 16 '12 at 12:26
0

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.

Scott Wales
  • 11,336
  • 5
  • 33
  • 30
0

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?

eriktous
  • 6,569
  • 2
  • 25
  • 35
0

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.

Beta
  • 96,650
  • 16
  • 149
  • 150