Mic*_*chi 4 c codeblocks c11 gcc5.2
就像标题所说,我需要code::blocks与之合作C11,我无法弄清楚如何去做.
我去了settings=> compiler settings=> Other options我添加-std=c11并尝试了-std=gnu11,两者似乎都没有用.
我编译gcc-5.2然后我更改了默认编译器(gcc-4.9)仍然没有结果.
当我尝试编译以下程序时:
#include<stdio.h>
int main(void){
int arr[] = {0,1,2,3,4};
for(int i=0;i<5;i++){
printf("%d ",arr[i]);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到以下内容:
|6|error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode|
Run Code Online (Sandbox Code Playgroud)
但如果我在终端(ubuntu 15.04,64BIT,gcc-5.2)中这样做:
./install/gcc-5.2.0/bin/gcc5.2 program.c -o program
Run Code Online (Sandbox Code Playgroud)
似乎工作正常.
我的问题是,如何code::blocks与之合作c11?
由于GCC 5.x版本-std=gnu11默认运行,因此Code :: Blocks必须对编译器执行某些操作(例如传递-ansi或-std=gnu90),以使其以不同方式工作.
调查发送到编译器的所有选项.找到一种方法让Code :: Blocks显示它在编译时使用的确切咒语.然后找出解决方法.
使用的选项是:
Run Code Online (Sandbox Code Playgroud)-Wall -Wextra -Werror -Wstrict-prototypes -Wconversion -std=gnu11 \ -O0 -g -ansi `pkg-config --cflags gtk+-3.0`
的-ansi是做损害; 它相当于-std=c90或许-std=gnu90- 它明确地撤消-std=c11或-std=gnu11.