最近在看android的binder,发现其代码中有一行:
2784 buffer = proc->buffer;
其中buffer类型为struct binder_buffer,proc->buffer为void *类型,编译当中没有给任何警告,觉得很奇怪,所以写了如下代码:
1 #include <stdio.h>
2
3 struct abc {
4 int a;
5 int b;
6 void *v;
7 };
8
9 int main()
10 {
11 int ret = 0;
12 struct abc abc;
13 struct abc *pabc;
14
15 pabc = abc.v;
16 abc.v = pabc;
17
18 return ret;
19 }
加上Wall编译也没任何警告,说明void *与其他类型转换时若不进行dereference就不会有任何警告,即认为正确。
找了下资料,没找到相关说明~