### c99

Controls the use of a subset of C99 language features.

##### Syntax

#pragma c99 on | off | reset

##### Targets

All platforms.

##### Remarks

Set pragma c99 on to tell the Carbide x86 compiler to use the following supported C99 language features:

- Trailing commas in enumerations
- GCC/C9x style compound literals

> #pragma c99 on
> struct my_struct {
> int i;
> char c[2];} my_var;
> my_var = ((struct my_struct) {x + y, 'a', 0});

- Designated initializers

> #pragma c99 on

> struct X {
> int a,b,c;
> } x = { .c = 3, .a = 1, 2 };

> union U {
> char a;
> long b;
> } u = { .b = 1234567 };

> int arr1[6] = { 1,2, [4] = 3,4 };
> int arr2[6] = { 1, [1 ... 4] = 3,4 }; // GCC only, not part of C99

- __func__ predefine
- Implicit return 0; in main()
- Non-const static data initialization
- Variable argument macros (__VA_ARGS__)
- bool / _Bool support
- long long support
- restrict support
- // comments
- inline support
- Digraphs
- _Complex and _Imaginary (treated as keywords but not supported)
- Empty arrays as last struct members

> struct {
> int r;
> char arr[];
> } s;

- Designated initializers
- Hexadecimal floating-point constants–precise representations of constants specified in hexadecimal notation to ensure an accurate constant is generated across compilers and on different hosts. The syntax is shown in Table 10.1.

> Constant Type | Format
> --- | ---
> hex-fp-constant | hex-string [ ‘.’ hex-string ] hex-exp [ size ]
> hex-string | hex-digit { hex-digit }
> hex-exp | ‘p’ decimal-string
> size | ‘f’ | ‘F’ | ‘l’ | ‘L’
> decimal-string | decimal-digit { decimal-digit }
> decimal-digit | <any decimal digit>
> hex-digit | <any hexadecimal digit>

> The compiler generates a warning when the mantissa is more precise than the host floating point format, and warnings are enabled. It generates an error if the exponent is too wide for the host float format.

> Examples include:

> 0x2f.3a2p3
> 0xEp1f
> 0x1.8p0L

> The standard library supports printing floats in this format using the “%a” and “%A” specifiers.

- Variable length arrays are supported within local or function prototype scope (as required by the C99 standard)

> // good example of C99 Variable Length Array usage

> #pragma c99 on
> void f(int n) {
> int arr[n];
> ...
> }

> While this example generates an error:

> // bad example of C99 Variable Length Array usage

> #pragma c99 on
> int n;
> int arr[n]; // generates an error: variable length array
> // types can only be used in local or
> // function prototype scope

> A variable length array cannot be used in a function template’s prototype scope or in a local template typedef, as shown below:

> // bad example of C99 usage in Function Prototype

> #pragma c99 on
> template<typename T> int f(int n, int A[n][n]);
> {
> } // generates an error: variable length arrays
> // cannot be used in function template prototypes
> // or local template variables

- Unsuffixed decimal constant rules supported

> // examples of C99 Unsuffixed Constants

> #pragma c99 on // and ULONG_MAX == 4294967295
> sizeof(4294967295) == sizeof(long long)
> sizeof(4294967295u) == sizeof(unsigned long)

> #pragma c99 off
> sizeof(4294967295) == sizeof(unsigned long)
> sizeof(4294967295u) == sizeof(unsigned long)

The following C99 features are not currently supported:

- long long bitfields on some targets
- ++bool-- expressions
- (T) (int-list) are handled/parsed as cast-expressions and as literals
- __STDC_HOSTED__ is 0
- <bool> op= <expr> does not always work correctly

This pragma corresponds to the Enable C99 Extensions setting . To check this setting, use __option(c99), described in Checking Settings. The default setting is off.