| | 1 | = C : Specification, Extensions, Subsets, Support = |
| | 2 | |
| | 3 | == See == |
| | 4 | |
| | 5 | * ExternalDefinitions |
| | 6 | * LocalDefinitions |
| | 7 | |
| | 8 | == C99 == |
| | 9 | |
| | 10 | * Specification of C99: [http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf SPEC] |
| | 11 | |
| | 12 | == Gnu Extensions == |
| | 13 | |
| | 14 | GNU extensions are documented in the [http://gcc.gnu.org/viewcvs/trunk/gcc/c-parser.c gcc C parser] |
| | 15 | and at http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html. |
| | 16 | |
| | 17 | Here is a summary of available extensions: |
| | 18 | |
| | 19 | === C99 6.5: Expressions === |
| | 20 | |
| | 21 | |
| | 22 | || [http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html Statement-Exprs] || Compound Statement as Expressions || |
| | 23 | || || {{{ #define maxint(a,b) ({int _a = (a), _b = (b); _a > _b ? _a : _b; }) }}} || |
| | 24 | |
| | 25 | || [http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html Labels-as-Values] || Taking the address of a label (see `Computed goto') || |
| | 26 | |
| | 27 | || [http://gcc.gnu.org/onlinedocs/gcc/Typeof.html Typeof] || compute type of expression || |
| | 28 | || || {{{ int x = 2; typeof(x) y = 3; }}} || |
| | 29 | |
| | 30 | || [http://gcc.gnu.org/onlinedocs/gcc/Conditionals.html Conditionals] || Omitting the middle operand of a `?:' expression || |
| | 31 | || || {{{ x ? : y }}} is equivalent to {{{ x ? x : y }}} || |
| | 32 | |
| | 33 | || [http://gcc.gnu.org/onlinedocs/gcc/Alignment.html Alignment] || Compute the alignment of an object || |
| | 34 | || || {{{ __alignof__ (double) }}} || |
| | 35 | |
| | 36 | || [http://gcc.gnu.org/onlinedocs/gcc/Offsetof.html Offsetof] || Compute offfset of member || |
| | 37 | |
| | 38 | || [http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html Other builtins] || Various builtin functions of gcc || |
| | 39 | || || {{{__builtin_types_compatible_p}}} is supported || |
| | 40 | |
| | 41 | || [http://gcc.gnu.org/onlinedocs/gcc/Complex.htm Complex numbers] || GNU complex extensions || |
| | 42 | || || {{{ __complex double c = 2 + 3i, d = __real a; }}} || |
| | 43 | |
| | 44 | || [http://gcc.gnu.org/onlinedocs/gcc/Character-Escapes.html Character-Escapes] || \e for ESC || |
| | 45 | || || {{{ char c = '\e' ; }}} || |
| | 46 | |
| | 47 | || {{{__builtin_va_arg}}} || {{{__builtin_va_arg}}} || |
| | 48 | |
| | 49 | |
| | 50 | === C99 6.7: Declarations === |
| | 51 | |
| | 52 | || [http://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html Empty-Structures] || Allow empty structures || |
| | 53 | || [http://gcc.gnu.org/onlinedocs/gcc/Incomplete-Enums.html Incomplete-Enums] || Allow incomplete enum definitions || |
| | 54 | || [http://gcc.gnu.org/onlinedocs/gcc/Initializers.html Initializers] ||Allow non-constant initializers || |
| | 55 | |
| | 56 | || [http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html Extended Asm] || Assembler instructions with C expressions as operands || |
| | 57 | |
| | 58 | || [http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html function attributes ] || Attributes annotating function declarations || |
| | 59 | || [http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html variable attributes ] || Attributes annotating variable declarations || |
| | 60 | || [http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html type attributes ] || Attributes annotating type declarations (struct, union) || |
| | 61 | |
| | 62 | || [http://gcc.gnu.org/onlinedocs/gcc/Thread_002dLocal.html Thread-Local] || Thread-local storage || |
| | 63 | |
| | 64 | === C99 6.8: Statements === |
| | 65 | |
| | 66 | || [http://gcc.gnu.org/onlinedocs/gcc/Local-Labels.html Local-Labels] || Labels local to a block (affects: C99 6.8.2) || |
| | 67 | || || {{{ do{ __label __ back; goto back; back: ...; }while(0); }}} || || || |
| | 68 | |
| | 69 | || [http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html Labels-as-Values] || Computed Gotos (affects: C99 6.8.6) || |
| | 70 | || || {{{ void* p = && back; ... ; goto *p; }}} || |
| | 71 | |
| | 72 | || [http://gcc.gnu.org/onlinedocs/gcc/Asm-Labels.html Asm-Labels] || Controlling Names Used in Assembler Code || |
| | 73 | |
| | 74 | || [http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html Nested-Functions] || nested functions || |
| | 75 | || || {{{ int a() { int b() { return 0;} return b(); } }}} || |
| | 76 | |
| | 77 | || [http://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html Case-Ranges] || case ranges (affects: C99 6.8.1) || |
| | 78 | || || {{{ case 'A' ... 'Z': }}} || |
| | 79 | |
| | 80 | === C99 6.9 :Translation unit === |
| | 81 | |
| | 82 | || Empty Translation unit || allow empty translation_unit || |
| | 83 | || Redundant ; || allow redundant ';' || |
| | 84 | || [http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html Alternate Keywords] || allow {{{__extension__}}} keyword before external declaration, and alternate keywards {{{__asm__}}}, {{{__inline__}}}, etc. || |
| | 85 | || [http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html Extended-Asm] || Top level asm definitions || |
| | 86 | |
| | 87 | === Extensions which do not apply === |
| | 88 | |
| | 89 | For completeness sake, the extensions |
| | 90 | [http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html Object Size Checking], |
| | 91 | [http://gcc.gnu.org/onlinedocs/gcc/Constructing-Calls.html Constructing-Calls], |
| | 92 | [http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Zero-Length Arrays], |
| | 93 | [http://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html Pointer-Arith], |
| | 94 | [http://gcc.gnu.org/onlinedocs/gcc/Cast-to-Union.html Cast-to-Union] and |
| | 95 | [http://gcc.gnu.org/onlinedocs/gcc/Function-Prototypes.html Function-Prototypes] |
| | 96 | listed on [http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html] do not affect the syntax of the program, |
| | 97 | and can therefore be considered as `supported'. |
| | 98 | |
| | 99 | |
| | 100 | Some other extensions simply promote C99 features to C89 and therefore aren't listed here. |
| | 101 | |
| | 102 | |
| | 103 | [http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html Variadic-Macros], |
| | 104 | [http://gcc.gnu.org/onlinedocs/gcc/Escaped-Newlines.html Escaped-Newlines], |
| | 105 | [http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Comments.html C++-Comments] apply to the preprocessor only. |
| | 106 | |
| | 107 | == Unsupported C99 Features == |
| | 108 | |
| | 109 | * Universal Character Names (C99 Lexer) |
| | 110 | |
| | 111 | === Currently Unsupported GNU Extensions === |
| | 112 | |
| | 113 | || Pragmas || {{{#pragma}}} compile directives || |
| | 114 | || || {{{ #pragma pack(push, p1, 1) }}} || |
| | 115 | || [http://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html Floating-Types] ||Additional Floating Types || |
| | 116 | || || {{{ __float80 x = 2.30w; }}} || |
| | 117 | || [http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html Decimal-Float] || Decimal Floating Types || |
| | 118 | || || {{{ __Decimal32 x = 0.555df; }}} || |
| | 119 | || [http://gcc.gnu.org/onlinedocs/gcc/Fixed_002dPoint.html Fixed_002dPoint] || Fixed-Point Types || |
| | 120 | || || {{{ _Sat long long _Fract pi = 3.14LLR }}} || |
| | 121 | || [http://gcc.gnu.org/onlinedocs/gcc/Dollar-Signs.html Dollar-Signs] || Dollar sign is allowed in identifier names || |
| | 122 | || || {{{ int $x = 3; }}} || |
| | 123 | || [http://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html Binary-constants] || Binary constants || |
| | 124 | || || {{{ int x = 0b001; }}} || |
| | 125 | |
| | 126 | === Unsupported non-standard C constructs (which GCC allows) === |
| | 127 | ==== useless qualifiers/type names/storage specs in empty declarations ==== |
| | 128 | {{{ |
| | 129 | int; |
| | 130 | const; |
| | 131 | static; |
| | 132 | void f(a,b) int; register; { } /* Empty declarations in old-style parameter declarations aren't supported either. */ |
| | 133 | }}} |
| | 134 | ==== obsolete use of designated initializer without ‘=’ ==== |
| | 135 | {{{ |
| | 136 | int e[] = { [2] 2 }; |
| | 137 | }}} |
| | 138 | ==== data definition without type or storage class ==== |
| | 139 | {{{ |
| | 140 | a; /* top-level declaration */ |
| | 141 | b(); |
| | 142 | }}} |
| | 143 | ==== GNU parameter forward declaration ==== |
| | 144 | {{{ |
| | 145 | int f1(int a; int a); |
| | 146 | }}} |
| | 147 | ==== no semicolon at end of struct or union ==== |
| | 148 | {{{ |
| | 149 | struct s3 { |
| | 150 | int d |
| | 151 | }; |
| | 152 | }}} |