具体是这样的,我定义了两个个结构体: ``` c++ typedef struct { void* input; void* output; } A; typedef struct { char* data1; int* data2; } B; ``` 在使用的时候做了如下操作 ``` c++ A* test; test->input = (B*)(test->input); test->output = (B*)(test->output); test->input->data1 = "hello"; *(test->input->data2) = 1; ``` 换了另一种写法也是报错 ``` c++ A* test; B* tmp1 = NULL; test->input = tmp1; test->input->data1 = "hello"; ``` 其中最后两句给data1和data2赋值的语句编译报错(ubuntu上的gcc),报错说data1、data2 in something not a struct or union 改成下列语句后编译通过了 ``` c++ A* test; B* tmp1; tmp1->data1 = "hello"; *(tmp1->data2) = 1; test->input = tmp1; ``` 想问为什么第一种写法不会通过? 另外想问下面这个写法能够通过编译吗? ``` c++ A* test; B* tmp1 = (B*)(test->input); tmp1->data1 = "hello"; ``` 已解决: 将其它类型的指针赋给void指针后,虽然可以赋值,但void指针本身的类型没有发生变化