读书人

众神, 小弟我来问个语法有关问题

发布时间: 2012-02-05 12:07:14 作者: rapoo

众神, 我来问个语法问题
在Linux2.6的源代码中, 有这种用法:

struct fs_struct {
int count;
int lock;
int umask;
int * root, * pwd, * altroot;
int * rootmnt, * pwdmnt, * altrootmnt;
};

#define INIT_FS {\
.count = 1,\
.lock = 0,\
.umask = 0022, \
}

static struct fs_struct init_fs = INIT_FS;


这个语法......, 编不过的.
就是 include\linux\fs_struct.h 中, 有兴趣的朋友可以看看.

[解决办法]
C99语法。gcc某些版本支持
你自己写代码的话,就忘了这个语法吧。
[解决办法]

C/C++ code
EXAMPLE 10 Structure members can be initialized to nonzero values without depending on their order:div_t answer = { .quot = 2, .rem = -1 };35 EXAMPLE 11 Designators can be used to provide explicit initialization when unadorned initializer listsmight be misunderstood:struct { int a[3], b; } w[] ={ [0].a = {1}, [1].a[0] = 2 };36 EXAMPLE 12 Space can be ‘‘allocated’’ from both ends of an array by using a single designator:int a[MAX] = {1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0}; 

读书人网 >C++

热点推荐