Calling convention for function returning struct

前端 未结 2 1767
孤街浪徒
孤街浪徒 2020-12-16 16:20

For the following C code:

struct _AStruct {
    int a;
    int b;
    float c;
    float d;
    int e;
};

typedef struct _AStruct AStruct;

AStruct test_cal         


        
2条回答
  •  眼角桃花
    2020-12-16 16:47

    There is no single "cdecl" calling convention. It is defined by the compiler and operating system.

    Also reading the assembly I am not actually sure the convention is actually different—in both cases the caller is providing buffer for the output as extra argument. It's just that gcc chose different instructions (the second extra sub is strange; is that code optimized?).

提交回复
热议问题