- 论坛徽章:
- 95
|
原帖由 ice-pl 于 2008-7-18 00:07 发表
The ISO C standard does not require that pointers to functions can be cast back and forth to pointers to data. Indeed, the ISO C standard does not require that an object of type void * can hold a pointer to a function. Implementations supporting the XSI extension, however, do require that an object of type void * can hold a pointer to a function. The result of converting a pointer to a function into a pointer to another data type (except void *) is still undefined, however. Note that compilers conforming to the ISO C standard are required to generate a warning if a conversion from a void * pointer to a function pointer is attempted as in:
fptr = (int (*)(int))dlsym(handle, "my_function");
OK, in this case I'm wrong!
不按照原来的方式转换,不论是直接把类型转换信息去掉,还是把类型转换信息放在右边,用如下方式编译都会出现警告:
gcc -pedantic --std=c99
默认情况下 gcc 并不是严格按照 ISO C 标准来的。
[ 本帖最后由 MMMIX 于 2008-7-18 21:50 编辑 ] |
|