Initializing Automatic Arrays and Structures

When the GCC extensions setting is on, array and structure variables that are local to a function and have the automatic storage class may be initialized with values that do not need to be constant. The following listing shows an example.

Listing: Initializing Arrays and Structures with Non-constant Values
void f(int i)

{

    int j = i * 10; /* Always OK. */

    /* These initializations are only accepted when GCC extensions

     * are on. */

    struct { int x, y; } s = { i + 1, i + 2 }; 

    int a[2] = { i, i + 2 };

}