diff -r 4891d49809bb -r 2b3996fc09a1 core/com.nokia.carbide.cpp.compiler.doc.user/html/pragmas/p_c99.htm --- a/core/com.nokia.carbide.cpp.compiler.doc.user/html/pragmas/p_c99.htm Mon Jul 19 15:31:48 2010 -0500 +++ b/core/com.nokia.carbide.cpp.compiler.doc.user/html/pragmas/p_c99.htm Mon Jul 19 16:13:24 2010 -0500 @@ -1,180 +1,180 @@ - - - - - - - c99 - - - - -

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:

- -
-
-

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

-
-
- -
-
-

#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

-
-
- -
-
-

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

-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Constant TypeFormat
hex-fp-constanthex-string [ ‘.’ hex-string ] hex-exp [ size ]
hex-stringhex-digit { hex-digit }
hex-exp‘p’ decimal-string
size‘f’ | ‘F’ | ‘l’ | ‘L’
decimal-stringdecimal-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.

-
- -
-
-

// 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

-
-
- -
-
-

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

- -

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.
-

-

- - - - - + + + + + + + c99 + + + + +

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:

+ +
+
+

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

+
+
+ +
+
+

#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

+
+
+ +
+
+

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

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Constant TypeFormat
hex-fp-constanthex-string [ ‘.’ hex-string ] hex-exp [ size ]
hex-stringhex-digit { hex-digit }
hex-exp‘p’ decimal-string
size‘f’ | ‘F’ | ‘l’ | ‘L’
decimal-stringdecimal-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.

+
+ +
+
+

// 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

+
+
+ +
+
+

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

+ +

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.
+

+

+ + + + +