<分区>
char*
、int*
、long*
甚至 long long*
是否具有相同的大小(在给定的平台)?
<分区>
char*
、int*
、long*
甚至 long long*
是否具有相同的大小(在给定的平台)?
最佳答案
虽然在我使用过的平台上它们通常是相同的,但不能保证它们的大小相同。
C 2011 online draft :
6.2.5 Types
...
28 A pointer tovoid
shall have the same representation and alignment requirements as a pointer to a character type.48) Similarly, pointers to qualified or unqualified versions of compatible types shall have the same representation and alignment requirements. All pointers to structure types shall have the same representation and alignment requirements as each other. All pointers to union types shall have the same representation and alignment requirements as each other. Pointers to other types need not have the same representation or alignment requirements.
48) The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and members of unions.
关于c - 对于所有数据类型,所有数据指针在一个平台中的大小是否相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1241205/