gcc_extensions

Controls the acceptance of GNU C language extensions.

Syntax

#pragma gcc_extensions on | off | reset

Targets
All platforms.
Remarks

If you enable this pragma, the compiler accepts GNU C extensions in C source code. This includes the following non-ANSI C extensions:

int foo(int arg)
{
int arr[2] = { arg, arg+1 };
}

pragma gcc_extensions on
#define POW2(n) ({ int i,r; for(r=1,i=n; i>0; --i) r<<=1; r;})

This feature only works for expressions in function bodies and does not support code that requires any form of C++ exception handling (for example, throwing or catching exceptions or creating local or temporary class objects that require a destructor call).

int main()
{
return POW2(4);
}

#pragma gcc_extensions on
struct S { int a, b, b; } s = { c:3, b:2, a:1 };

#pragma gcc_extensions on
int x, y, z;
x = y ?: z;
Outputs:
x = y ? y ? z;

This pragma corresponds to the Enable GCC Extensions setting . To check the global optimizer, use __option (gcc_extensions), described in Checking Settings. The default setting is off.