I want to activate c99 mode in gcc compiler to i read in other post in this forum that -std
should be equal to -std=c99
but i don't know how to set it to this value using command line so please help.

- 363,768
- 54
- 674
- 675

- 417
- 1
- 4
- 12
-
2append your command with -std=c99 ;) – Tymoteusz Paul Aug 29 '14 at 10:39
-
How do you specify the name of the executable? – jxh Aug 29 '14 at 10:41
-
Use the command `c99` to compile programs written in the language C99 ;-) – Marc Glisse Oct 22 '16 at 06:57
3 Answers
Compile using:
gcc -std=c99 -o outputfile sourcefile.c
gcc --help
lists some options, for a full list of options refer to the manuals. The different options for C dialect can be found the section "Options Controlling C Dialect" in any gcc
version's manual (e.g., here).
As you are using make
you can set the command line options for gcc using CFLAGS
:
# sample makefile
CC = gcc
CFLAGS = -Wall -std=c99
OUTFILE = outputfile
OBJS = source.o
SRCS = source.c
$(OUTFILE): $(OBJS)
$(CC) $(CFLAGS) -o $(OUTFILE) $(OBJS)
$(OBJS): $(SRCS)
$(CC) $(CFLAGS) -c $(SRCS)
Addendum (added late 2016): C99 is getting kind of old by now, people looking at this answer might want to explore C11 instead.
-
thanks but does this replace make because i always use make to compile all my programs ? – user297904 Aug 29 '14 at 10:51
-
@user297904 No, if you use a makefile you should set the options in it instead. I'll update my answer with an example. – jpw Aug 29 '14 at 10:54
-
thanks for the update one last question should write into terminal or inside of configuration file of make and where is the configuration file of make ? – user297904 Aug 29 '14 at 11:18
-
@user297904 When you use make you have a makefile that tells make what to do when you invoke it. The sample I added is a basic makefile that compiles a c-file named source.c in the same directory and creates an executable file called `outputfile` – jpw Aug 29 '14 at 11:20
-
Two years after I wrote this I still get some upvotes, which of course is nice, but it might time to leave C99 behind and move on to newer standards (ie. using `-std=c11` for C11 instead). – jpw Oct 22 '16 at 00:17
You may try to use the -std=c99
flag.
Try to complile like this:
gcc -Wall -std=c99 -g myProgram.c
Also note that -g
is for debugging option(Thanks Alter Mann for pointing that).

- 168,305
- 31
- 280
- 331
Based on the comments under another answer, perhaps you are using the implicit make rules and don't have a Makefile. If this, then you are just runing make tst
to generate tst binary from tst.c. In that case you can specify the flags by setting the environment variable CFLAGS
. You can set it for the current shell, or add it to your ~/.bashrc
to have it always, with this:
export CFLAGS='-Wall -Wextra -std=c99'
Or specifying it just for the single command:
CFLAGS='-Wall -Wextra -std=c99' make tst
(Note: I added warning flags too, you should really use them, they will detect a lot of potential bugs or just bad code you should write differently.)

- 60,639
- 21
- 115
- 176