How to use C11 standard in Code::Blocks
c, c11, codeblocks, gcc5.2
Solution
Since the GCC 5.x versions run with `-std=gnu11` by default, Code::Blocks must be doing something (such as passing `-ansi` or `-std=gnu90`) to the compiler to make it work differently.
Investigate all the options that are sent to the compiler. Find a way to have Code::Blocks show you the exact incantation it uses when compiling. Then work out how to fix it.
Options that are used are:
-Wall -Wextra -Werror -Wstrict-prototypes -Wconversion -std=gnu11 \
-O0 -g -ansi `pkg-config --cflags gtk+-3.0`
The `-ansi` is doing the damage; it is equivalent to `-std=c90` or perhaps `-std=gnu90` — it explicitly undoes `-std=c11` or `-std=gnu11`.
Problem
Like the Title says I need to make `code::blocks` to work with `C11` and I can't figure out how to do it. I went to `settings` => `compiler settings` => `Other options` and I added `-std=c11` and tried also with `-std=gnu11`, both doesn't seems to work. I compiled `gcc-5.2` and then I changed the default compiler (gcc-4.9) and still no result. When I try to compile the following program: ``` #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; } ``` I get the following: ``` |6|error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode| ``` But if I do it in terminal (ubuntu 15.04, 64BIT, gcc-5.2): ``` ./install/gcc-5.2.0/bin/gcc5.2 program.c -o program ``` Seems to work fine. My question is, how to make `code::blocks` to work with `c11` ?