GCC对C语言的扩展01

本系列参考 Using the GNU Compiler Collection. For GCC version 4.6.1.  第6章

6 Extensions to the C Language Family

GNU C provides several language features not found in ISO standard C. (The '-pedantic'

option directs GCC to print a warning message if any of these features in used.) To test for

the availability of these features in conditional compilation, check for a predefined macro

__GUNC__, which is always defined under GCC.

  These extensions are available in C and Objective-C. Most of them are also available in 

C++.

  Some features that are in ISO C99 but not C90 or C++ are also, as extensions, accepted

by GCC in C90 mode and in C++.

6.1、Statements and Declarations in Expressions

A compound statement enclosed in parentheses may appear as an expression in GNU C.

This allows you to use loops, switches, and local variables within an expression.

  Recall that a compound statement is a sequence of statements surrounded by braces; in

this construct, parentheses go around the braces. For example:

            ({  int y = foo(); int z;

                 if (y > 0) z = y;

                 else z = -y;

                 z;  })

is a valid(though slightly more complex than necessary) expression for the absolute value

of foo().

  The last thing in the compound statement should be an expression


你可能感兴趣的:(GCC对C语言的扩展01)