Michi Michi - 2 months ago 30x
C Question

How to use C11 standard in Code::Blocks

Like the Title says I need to make

to work with
and I can't figure out how to do it.

I went to
compiler settings
Other options
and I added
and tried also with
, both doesn't seems to work.

I compiled
and then I changed the default compiler (gcc-4.9) and still no result.

When I try to compile the following program:


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
to work with


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.