一、指定数组初始化
int arry[6] = { [4] = 29, [2] = 15 }; //指定arry[4]=29, arry[2]=15 ,其他的为0
等价于
int arry[6] = { 0, 0, 15, 0, 29, 0 };
类似于注定结构体初始化
二、空结构体,C89标准的结构体不支持空结构体的。。
struct empty {
};
三、C++一样的注释符号 //
四、支持inline类联函数
static inline int
inc (int *a)
{
return (*a)++;
}
__inline__ 在一个头文件中使用 __inline__ 声明inline函数,因为ISO C90没有inline,这个时候就会被解释成空,忽略掉他。。。
五、声明时使用变量初始化
foo (float f, float g)
{
float beat_freqs[2] = { f-g, f+g };
/* ... */
}
六、标识符允许添加美元符号
七、老式的函数定义不在支持
/* Old-style function definition. */
int
isroot (x) /* ??? lossage here ??? */
uid_t x;
{
return x == 0;
}
八、case语句的范围caselow ...high:
像 case 'A'...'Z':
case 1...5:
九、多了一个转义字符 '\e' ,表示 <ESC>
十、类型转换可以转成union类型
union foo { int i; double d; };
int x;
double y;
union foo u;
/* ... */
u = (union foo) x == u.i = x
u = (union foo) y == u.d = y
十一、变量、函数和类型可以添加属性 __attribute__
十二、数组可以用restrict修饰, 想 arry_name[restrict]
十三、支持复数运算
十四、支持嵌套函数(Nested Functions)
foo (double a, double b)
{
double square (double z) { return z * z; }
return square (a) + square (b);
}
十五、修改了条件运算符
原先的是:
x?x:y;
C99可以写成:
x ? : y;
十六、标签即变量
static void *array[] = { &&foo, &&bar, &&hack };
goto *array[i];
十七、支持变参宏
#define ENABLE_DEBUG 1 //else, comment this line
#ifdef ENABLE_DEBUG
#define DEBUG_LOG(fmt,...) fprintf(stderr, "%s:%d: " fmt "\n", \
__func__, __LINE__, ## __VA_ARGS__)
#else
#define DEBUG_LOG(fmt, ...) do {} while (0)
#endif
等等。。。。。。。。。。。。。。