access_errors

### 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:

- Initialization of automatic struct or array variables with non-const values

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

- sizeof( void ) == 1
- sizeof( function-type ) == 1
- Limited support for GCC statements and declarations within expressions

> 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);
> }

- Macro redefinitions without a previous #undef.
- The GCC keyword typeof. See “The __typeof__() and typeof() operators”, “Initialization of Local Arrays and Structures” for a description of these extensions.
- Function pointer arithmetic supported
- void* arithmetic supported
- __builtin_constant_p (<expr>) supported
- Forward declarations of arrays of incomplete type supported
- Pre-C99 designated initializer syntax (deprecated) supported

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

- Conditionals with omitted Operands supported

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

- long __builtin_expect (long exp, long c) now accepted

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.