Go to main content
Oracle® Developer Studio 12.6: C User's Guide

Exit Print View

Updated: July 2017
 
 

2.15 Extensions

The C compiler implements a number of extensions to the C language.

2.15.1 _Restrict Keyword

The C compiler supports the _Restrict keyword as an equivalent to the restrict keyword in the C 99 standard. The _Restrict keyword is available with any -std flag value when -pedantic is not specified, whereas the restrict keyword is only available with -std=c99 or -std=c11.

For more information about supported C 11 features, see Features of C 11.

For more information about supported C 99 features, see Features of C 99.

2.15.2 __asm Keyword

The __asm keyword (note the initial double-underscore) is a synonym for the asm keyword. The compiler will issue a warning for uses of the asm keyword when -pedantic is in effect. Use __asm to avoid these warnings. The __asm statement has the form:

__asm("string");

where string is a valid assembly language statement.

The statement emits the given assembler text directly into the assembly file. A basic asm statement declared at file scope, rather than function scope, is referred to as a global asm statement. Other compilers refer to this as a toplevel asm statement.

Global asm statements are emitted in the order they are specified, retaining their order relative to each other and maintaining their position relative to surrounding functions.

At higher optimization levels, the compiler may remove functions that it has determined are not referenced. Because the compiler cannot evaluate which functions are referenced from within global assembly language statements, they might be removed inadvertently.

Note that extended asm statements, those which provide a template and operand specifications, are not allowed to be global. __asm and __asm__ are synonyms for the asm keyword and can be used interchangeably.

When specifying architecture-specific instructions it might be necessary to specify an appropriate -xarch value to avoid compilation errors.

2.15.3 __inline and __inline__

__inline and __inline__ are synonyms for the inline keyword (C standard, section 6.4.1)

2.15.4 __builtin_constant_p()

__builtin_constant_p is a compiler builtin function. It takes a single numeric argument and returns 1 if the argument is a compile-time constant. A return value of 0 means that the compiler can not determine whether the argument is a compile-time constant. A typical use of this built-in function is in manual compile-time optimizations in macros.

2.15.5 __FUNCTION__ and __PRETTY_FUNCTION__

__FUNCTION__ and __PRETTY_FUNCTION__ are predefined identifiers that contain the name of the lexically enclosing function. They are functionally equivalent to the predefined identifier, __func__. On Oracle Solaris platforms, __FUNCTION__ and __PRETTY_FUNCTION__ are not available in -Xs and -Xc modes or when -pedantic is in effect.

2.15.6 untyped _Complex

As an extension, untyped _Complex now defaults to double _Complex under the default language standard option. With -pedantic (strict conformance with errors/warnings for non-ANSI constructs), a warning is generated.

2.15.7 __alignof__

The __alignof__ operator allows you to inquire about how an object is aligned, or the minimum alignment usually required by a type. Its syntax is just like sizeof.

For example, __alignof__ (float) is 4.

If the operand of __alignof__ is an object rather than a type, its value is the required alignment for its type, taking into account any minimum alignment specified with an alignment related __attribute__ extension.

2.15.8  __atomic built-ins

The Oracle Developer Studio C compiler implements the gcc __atomic built-in functions for memory model aware atomic operations.