This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C calling conventions: how to pass a struct parameter?


Cezar Harabula <cezar.harabula@open-plug.com> writes:

> Thank you for your answers. Unfortunately, I was not clear enough. I
> want to know what happens in the registers and in the stack when a
> procedure like
> 
> void PrintFoo(struct Foo foo)
> 
> is called. There is no universal C calling convention set for x86,  so
> I am interested in how GCC usually does.
> 
> What about a struct return value:
> struct bar Function() ?

The easy way to find out is to write some code and look at the result
when it is compiled using -S.  The results will change if you use the
-mregparm option.

Structures are normally passed by pushing the value of the structure
on the stack.

Structures are normally returned by arranging for the caller to pass
the address of a memory area as a hidden first argument.  The function
then stores the return value into that memory area.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]