简体   繁体   English

test.c:51:4:错误:从类型'void *'分配给类型'blk时,类型不兼容

[英]test.c:51:4: error: incompatible types when assigning to type ‘blk from type ‘void *’

    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

Thanks. 谢谢。

blk b;

is the same as: 是相同的:

abc b[1];

b is not a pointer in the sense that you are using it. b在您使用它的意义上不是指针。

b = shmat(shmid, NULL, 0);

is incorrect because you can't assign a pointer to an array. 是不正确的,因为您不能将指针分配给数组。 That is wrong exactly the way the following is wrong. 这完全是错误的,就像以下错误一样。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:从“void *”类型分配类型“值”时出现不兼容的类型? - Error: incompatible types when assigning to type 'values' from type 'void *'? 从C中的类型分配类型时出错类型不兼容 - error incompatible types when assigning to type from type in C 错误:分配给类型 'BusRoute' {aka 'struct 时的类型不兼容<anonymous> '} 来自类型 'void *'</anonymous> - error: incompatible types when assigning to type ‘BusRoute’ {aka ‘struct <anonymous>’} from type ‘void *’ 编译器错误:在malloc期间从类型&#39;void *&#39;分配给&#39;struct&#39;时出现不兼容的类型 - Compiler error: incompatible types when assigning to 'struct' from type 'void *' during malloc 错误:从类型&#39;digestInfo&#39;分配给类型&#39;char *&#39;时类型不兼容 - error: incompatible types when assigning to type ‘char *’ from type ‘digestInfo’ C 分配给相同类型的变量时出现类型不兼容错误 - C incompatible types error when assigning to variable of same type 错误:分配和返回类型时类型不兼容 - Error: incompatible types when assigning to and returning to type 从可可项目中的不兼容类型“ void *”错误分配给“ MyPrivateData *” - Assigning to “MyPrivateData *” from incompatible type 'void *' error in cocoa project 从“ int”类型分配给“ memstruct”类型时不兼容的类型 - incompatible types when assigning to type ‘memstruct’ from type ‘int’ 从“数组*”类型分配给“数组[256]”类型时不兼容的类型 - incompatible types when assigning to type 'array[256]' from type 'array *'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM