我正在研究在OSX上使用的x86_64的调用约定,并且在System V x86-64 ABI标准中阅读了名为"Aggregates and Unions"的部分.它提到了数组,我认为这就像一个固定长度的c数组,例如int[5]
.
我下到"3.2.3参数传递"来读取数组如何通过,如果我正确理解,uint8_t[3]
应该在寄存器中传递一些东西,因为它小于聚合分类规则1规定的四个八字节限制类型(靠近底部的第18页).
编译后我看到它被作为指针传递.(我正在使用OSX 10.11.6上的Xcode 7.3.1中的clang-703.0.31进行编译).
我用来编译的示例源如下:
#include <stdio.h>
#define type char
extern void doit(const type[3]);
extern void doitt(const type[5]);
extern void doittt(const type[16]);
extern void doitttt(const type[32]);
extern void doittttt(const type[40]);
int main(int argc, const char *argv[]) {
const char a[3] = { 1, 2, 3 };
const char b[5] = { 1, 2, 3, 4, 5 };
const char c[16] = { 1, 2, 3, 4, 5, 6, …
Run Code Online (Sandbox Code Playgroud)