使用 gcc (GCC) 4.4.6 ,我尝试编译这个程序 -
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main(int argc, char *argv[])
5 {
6
7 struct B {
8 int i;
9 char ch;
10 };
11
12 struct B *ptr;
13
14 ptr = (struct B*) calloc(1, sizeof(struct B));
15
16 *ptr = {
17 .i = 10,
18 .ch = 'c',
19 };
20
21 printf("%d,%c\n", ptr->i, ptr->ch);
22
23 return 0;
24 }
25
$ make
gcc -g -Wall -o test test.c
test.c: In function ‘main’:
test.c:16: error: expected expression before ‘{’ token
make: *** [test] Error 1