[解决办法] 这个应该查C语言标准的C99 6.3.2.3 Pointers 1 A pointer to void may be converted to or from a pointer to any incomplete or object type. A pointer to any incomplete or object type may be converted to a pointer to void and back again; the result shall compare equal to the original pointer. 。。。 6。。。 7。。。
[解决办法] 翻了一下C99,不巧,只有sizeof(char)==1,其它的没具体限制。 倒是有暗示可以不相等的: 7.18.1.4 Integer types capable of holding object pointers 1 The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: intptr_t The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: uintptr_t These types are optional. 那啥,成员指针大小各个编译器都不见得一样,像32位DMC++就都4字节,其它的8~20字节不等,取决于是否用到多继承/虚继承等等。。 找了一下,记得这篇文章里面应该有张表(我这里现在莫名其妙打不开……): http://www.codeproject.com/KB/cpp/FastDelegate.aspx [解决办法]
[解决办法] 给你贴上The C Programming Language 上的一段原话: A.6.8 Pointers to Void Any pointer to an object may be converted to type void * without loss of information. If the result is converted back to the original pointer type, the original pointer is recovered. Unlike the pointer-topointer conversions discussed in Par.A.6.6, which generally require an explicit cast, pointers may be assigned to and from pointers of type void *, and may be compared with them. void *类型的宽度是最大的,任何类型转换成void *都不会有信息丢失。 [解决办法] 关于类成员函数的指针的长度是和继承有关的,指向“类”的成员函数的指针不仅包含成员函数地址的信息,而且包含与类的属性有关的信息。在32位操作系统中,一般函数的指针的长度为4个字节(32位),无继承关系类的成员函数的指针长度为4字节(32位),普通继承关系的类成员函数的指针长度是8字节,有虚继承关系类成员函数的指针长度是12字节。