如何在带有终端的gcc中启用c99模式 [英] How enable c99 mode in gcc with terminal
本文介绍了如何在带有终端的gcc中启用c99模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在gcc编译器中激活c99模式,以便在本论坛的其他帖子中阅读 -std
应该等于 -std = c99
,但我不知道不知道如何使用命令行将其设置为该值,所以请帮忙.
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.
推荐答案
使用以下命令编译:
gcc -std=c99 -o outputfile sourcefile.c
gcc --help
列出了一些选项,有关选项的完整列表,请参考
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.
使用 make
时,可以使用 CFLAGS
设置gcc的命令行选项:
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)
附录(于2016年末添加):C99到现在已经有些陈旧了,看到此答案的人们可能想探索 C11 .
这篇关于如何在带有终端的gcc中启用c99模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文