c - 对于所有数据类型,所有数据指针在一个平台中的大小是否相同?

标签 c pointers types

<分区>

char*int*long* 甚至 long long* 是否具有相同的大小(在给定的平台)?

最佳答案

虽然在我使用过的平台上它们通常是相同的,但不能保证它们的大小相同。

C 2011 online draft :

6.2.5 Types
...
28     A pointer to void 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/

相关文章:

java - Java 类定义中重载类型参数

python - 如何让 mypy 识别或忽略动态导入的类型?

c - windows下C语言中数据的字节表示。大端和小端

c - 重写旧版 cpufreq_driver 的 cpufreq_freq_table 初始化

c++ - 取消引用 NULL 指针是否保证使 C/C++ 中的程序崩溃?

c - c中指向指针赋值的指针

scala - 为什么我们可以在 Scala 中使用新类作为父类的类型?

c - 排序数组在 ANSI C 中不起作用

c - 替换c中二维数组中的值

c - 指针还是地址?