且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否所有的数据指针在一个平台上同样大小的所有数据类型?

更新时间:2023-02-09 20:32:18

他们不能保证是相同的大小,但在平台上我有经验,他们通常是。

They're not guaranteed to be the same size, although on the platforms I have experience with they usually are.

6.2.5.27:

要作废的指针应具有相同的重presentation和对齐要求作为
  指针指向一个字符type.39)同样指向合格的或不合格的版本
  兼容类型应具有相同的重presentation和对齐要求。所有指针结构类型应具有相同的重presentation和对齐要求
  彼此。所有指向联合类型应具有相同的重presentation和
  对齐要求对方。指针到其它类型的不必具有相同的
  再presentation或对齐要求。

A pointer to void shall have the same representation and alignment requirements as a pointer to a character type.39) 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.