C : Specification, Extensions, Subsets, Support



Gnu Extensions

GNU extensions are documented in the gcc C parser and at

Here is a summary of available extensions:

C99 6.5: Expressions

Statement-Exprs Compound Statement as Expressions
#define maxint(a,b) ({int _a = (a), _b = (b); _a > _b ? _a : _b; })
Labels-as-Values Taking the address of a label (see `Computed goto')
Typeof compute type of expression
int x = 2; typeof(x) y = 3;
Conditionals Omitting the middle operand of a `?:' expression
x ? : y is equivalent to x ? x : y
Alignment Compute the alignment of an object
__alignof__ (double)
Offsetof Compute offfset of member
Other builtins Various builtin functions of gcc
__builtin_types_compatible_p is supported
Complex numbers GNU complex extensions
__complex double c = 2 + 3i, d = __real a;
Character-Escapes \e for ESC
char c = '\e' ;
__builtin_va_arg __builtin_va_arg

C99 6.7: Declarations

Empty-Structures Allow empty structures
Incomplete-Enums Allow incomplete enum definitions
Initializers Allow non-constant initializers
Extended Asm Assembler instructions with C expressions as operands
function attributes Attributes annotating function declarations
variable attributes Attributes annotating variable declarations
type attributes Attributes annotating type declarations (struct, union)
Thread-Local Thread-local storage

C99 6.8: Statements

Local-Labels Labels local to a block (affects: C99 6.8.2)
do{ __label __ back; goto back; back: ...; }while(0);
Labels-as-Values Computed Gotos (affects: C99 6.8.6)
void* p = && back; ... ; goto *p;
Asm-Labels Controlling Names Used in Assembler Code
Nested-Functions nested functions
int a() { int b() { return 0;} return b(); }
Case-Ranges case ranges (affects: C99 6.8.1)
case 'A' ... 'Z':

C99 6.9 :Translation unit

Empty Translation unit allow empty translation_unit
Redundant ; allow redundant ';'
Alternate Keywords allow __extension__ keyword before external declaration, and alternate keywards __asm__, __inline__, etc.
Extended-Asm Top level asm definitions

Extensions which do not apply

For completeness sake, the extensions Object Size Checking, Constructing-Calls, Zero-Length Arrays, Pointer-Arith, Cast-to-Union and Function-Prototypes listed on do not affect the syntax of the program, and can therefore be considered as `supported'.

Some other extensions simply promote C99 features to C89 and therefore aren't listed here.

Variadic-Macros, Escaped-Newlines, C++-Comments apply to the preprocessor only.

Unsupported C99 Features

  • Universal Character Names (C99 Lexer)

Currently Unsupported GNU Extensions

Pragmas #pragma compile directives
#pragma pack(push, p1, 1)
Floating-Types Additional Floating Types
__float80 x = 2.30w;
Decimal-Float Decimal Floating Types
__Decimal32 x = 0.555df;
Fixed_002dPoint Fixed-Point Types
_Sat long long _Fract pi = 3.14LLR
Dollar-Signs Dollar sign is allowed in identifier names
int $x = 3;
Binary-constants Binary constants
int x = 0b001;

Unsupported non-standard C constructs (which GCC allows)

useless qualifiers/type names/storage specs in empty declarations

void f(a,b) int; register; { } /* Empty declarations in old-style parameter declarations aren't supported either. */

obsolete use of designated initializer without ‘=’

int e[] = { [2] 2 };

data definition without type or storage class

a;  /* top-level declaration */

GNU parameter forward declaration

int f1(int a; int a);

no semicolon at end of struct or union

struct s3 {
  int d
Last modified 9 years ago Last modified on Dec 19, 2009, 11:35:49 PM