run_xiao2000 发表于 2008-07-14 15:56

C99增加文法特性

研究了一下C99标准文档,并对照 http://linux.chinaunix.net/bbs/thread-885847-1-1.html 比较了一下下,C99主要增加了下面几个文法特性:

1. declaration_specifiers中增加了function_secifier,也就是增加了inline函数的特性

2. type_specifiers中增加了_Bool,_Complex,_Imaginary,应该是可支持布尔型及复数类型。

3.支持声明可变长度数组类型,
direct-declarator:
identifier         |
( declarator )    |
direct-declarator[ type-qualifier-listopt assignment-expressionopt ]         |
direct-declarator    |
direct-declarator[ type-qualifier-list static assignment-expression ]          |
direct-declarator [ type-qualifier-listopt *]                                                 |
direct-declarator( parameter-type-list)                                                      |
direct-declarator( identifier-listopt )                                                         |

中间那段看了好几次没看懂

4.compound_statement 中可在使用变量时再声明,无需再开始就先声明

5.可 for 中初始声明下标变量

6.可直接初始化struct和union内的成员,比如

div_t answer = { .quot = 2, .rem = -1 };

union { /* ... */ } u = { .any_member = 42 };

struct { int a, b; } w[] ={ .a = {1}, .a = 2 };

以及为数组两端赋值:
int a = {
          1, 3, 5, 7, 9, = 8, 6, 4, 2, 0
};
页: [1]
查看完整版本: C99增加文法特性