2007年1月31日星期三

GCC Extension

http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Designated-Inits.html#Designated-Inits

1. To initialize a range of elements to the same value, write `[first ... last] = value'. This is a GNU extension. For example,

     int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };


2. In a structure initializer, specify the name of a field to initialize with `.fieldname =' before the element value. For example, given the following structure,

struct point { int x, y; };

the following initialization

struct point p = { .y = yvalue, .x = xvalue };

没有评论: