[英]request for member is not a struct or union in C
I have a struct containing an int variable. 我有一个包含int变量的结构。
typedef struct _details_t{
int id;
int offset;
int buff[4];
}details_t;
in the main I have attached the shared memory to the pointer which is of structure type as above 在主体中,我已将共享内存附加到指针,指针的结构类型如上所述
int set_shm_data(details_t** details){
if(NULL == details || *details == NULL){
//error
}
*details->id = 345;
return -1;
}
int main(){
details_t* shmat;
....
....
shmat = (details_t *)shmat(shmid,(void *)0,0);
if(NULL == shmat){
//error
}
if(-1 == set_shm_data(&shmat)){
//error
}
return 0;
}
I'm getting an error "request for member is not a struct or union" . 我收到错误消息“要求成员不是结构体或联合体”。 I have checked the syntax and the calling and accessing methods. 我已经检查了语法以及调用和访问方法。 Nothing appears to be wrong to get this error. 似乎没有任何错误要解决此错误。
The problem is here: 问题在这里:
*details->id = 345;
The ->
operator binds more tightly than *
, so you need to use parentheses: ->
运算符比*
绑定更紧密,因此您需要使用括号:
(*details)->id = 345;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.