Restrictions

The new C11 compiler, initially for the SPARC computer, has a number of built in restrictions, some of which make the source code more legible.

Compound Literals

Standard C allows literals and initialisers to be written with fewer values than the type requires. For example we can write:

int a[3][4] = {1, 2, 3, 4};

This initialiser has too few values (it should have 12). And the values are not formatted for a two-dimensional array.

This is how you write the initialiser in full:

int a [3][4] = { {1, 2, 3, 4}, {11, 12, 13, 14}, {21, 22, 23, 24} };

The XGC compiler allows missing values but does not support missing nesting, so the following is allowable:

int a [3][4] = { {1, 2, 3, 4} };

Of course the missing values default to zero.

Leave a Reply

Your email address will not be published. Required fields are marked *