如何在 Eclipse 中配置 GCC 以使用 C99?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4236323/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you configure GCC in Eclipse to use C99?
提问by Dai
I'm working on a small C project in Eclipse; I just installed Eclipse from the Ubuntu Software Center and added C/C++ Language Support. I can build, run, and debug simple C programs fine.
我正在 Eclipse 中开发一个小型 C 项目;我刚刚从 Ubuntu 软件中心安装了 Eclipse 并添加了 C/C++ 语言支持。我可以很好地构建、运行和调试简单的 C 程序。
But I'm using some C99 features now, and Eclipse complains, saying "'for' loop initial declarations are only allowed in C99 mode".
但是我现在正在使用一些 C99 功能,Eclipse 抱怨说“'for' 循环初始声明只允许在 C99 模式下使用”。
I thought you'd set C99 mode for GCC in the makefile, but the makefile is auto-generated by Eclipse so any changes I make would be overwritten, but I don't see anywhere to put GCC compiler options anywhere in Eclipse's preferences nor my Project Properties windows.
我以为你会在 makefile 中为 GCC 设置 C99 模式,但是 makefile 是由 Eclipse 自动生成的,所以我所做的任何更改都将被覆盖,但是我没有看到任何地方可以将 GCC 编译器选项放在 Eclipse 的首选项中的任何位置,也不是我的项目属性窗口。
So where do I define C99 mode?
那么我在哪里定义 C99 模式呢?
回答by Giuseppe
Go into project properties. Search for C/C++Build -> Settings. In the Tool Settings tab search for GCC C compiler and then Miscellaneous. In other flags text box add the -std=c99. It should work fine.
进入项目属性。搜索 C/C++Build -> 设置。在工具设置选项卡中搜索 GCC C 编译器,然后搜索杂项。在其他标志文本框中添加 -std=c99。它应该可以正常工作。