Possible Duplicate:
sizeof (int) == sizeof (void*)?
我想知道是否可以保证,在 32 位和 64 位系统中,sizeof(int)
总是等于 sizeof(void*)
(即分别为 32 位和 64 位)。
此外,我需要知道是否始终保证 long int
可以容纳 int
和 void*
的位一起,例如
long int lint = (((int)integer)<<sizeof(int)) | (void*)ptr;
I was wondering whether it is guaranteed that, in both 32-bit and 64-bit systems, sizeof(int)
is always equal to sizeof(void*)
没有。
I need to know whether it is always guaranteed that a long int
can accommodate the bits of an int
and a void*
together
没有。一个快速证明是在 许多 现代平台上考虑 sizeof(long int) == sizeof(int)
,可能包括您正在使用的平台。
更重要的问题是为什么您认为您“需要知道”这个;事实上,您问这样的问题让我担心您的代码可能会……摇摆不定。