Liste des Groupes | Revenir à cl c |
On 08/07/2024 19:39, BGB wrote:
Arrays are passed by reference:Though, this one seems to be a common point of divergence between "SysV" and "Microsoft" ABIs. Sometimes a target will have an ABI defined, and the MS version was almost the same, just typically differing in that it passes structs by reference and provides a spill space for register arguments.I don't think it is helpful that you keep mixing /logical/ terms with /implementation/ terms.
>
In C, there is no "pass by reference" or "return by reference". It is all done by value.
So if you have these structs and declarations :From what I've seen, structs that are not small enough to be passed in registers, are copied to a temporary, and the address of that temporary is passed.
struct small { uint16_t a; uint16_t b; };
struct big { uint32_t xs[10]; };
struct small foos(struct small y);
struct big foob(struct big y);
Then compilers will typically implement "x = foos(y)" as though it were:
extern uint32_t foos(uint32_t ab);
uint32_t _1 = foos(y.a << 16) | (y.b);
struct small x = { _1 >> 16, _1 & 0xffff };
And they will typically implement "x = foosb(y)" as though it were:
extern void foob(struct big * ret, const struct big * xs);
struct big x;
foob(&x, &y);
Les messages affichés proviennent d'usenet.