是否可以为某些结构成员设置默认值?我尝试了以下操作,但会导致语法错误:
typedef struct
{
int flag = 3;
} MyStruct;
错误:
$ gcc -o testIt test.c
test.c:7: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
test.c: In function ‘main’:
test.c:17: error: ‘struct <anonymous>’ has no member named ‘flag’