test.c:51:4:错误:分配类型'blk from type'void *'时出现不兼容的类型

时间:2014-12-22 22:50:22

标签: c types struct void-pointers

    typedef struct abc{

        int a;
        char b;

    }abc;

    typedef abc bkl[1];
    .
    .
    .

    blk b;

b=shmat(shmid, NULL, 0); //This error that (Void *) to blk 
                              //But anyway blk is pointer,it isnt ? 

blk *b;
b=shmat(shmid, NULL, 0); //This is correct, why? b pointor to pointer

感谢。

1 个答案:

答案 0 :(得分:4)

blk b;

与:

相同
abc b[1];

b在您使用它的意义上不是指针。

b = shmat(shmid, NULL, 0);

不正确,因为您无法指定指向数组的指针。这完全是以下错误的方式。

int arr[3];
arr = malloc(sizeof(int)*10);