user297904 user297904 - 3 years ago 253
C Question

How enable c99 mode in gcc with terminal

I want to activate c99 mode in gcc compiler to i read in other post in this forum that

should be equal to
but i don't know how to set it to this value using command line so please help.

jpw jpw
Answer Source

Compile using:

gcc -std=c99 -o outputfile sourcefile.c

gcc --help lists some options, for a full list of options refer to the manual. The different options for C dialect can be found 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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download