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: problem with solaris compiler


Hi Priya,

> why does a compiler push the arguments from left to right or right to
> left in a function call (especially with respect to gcc)?

GCC uses the calling convention that is appropriate for the platform.

There are several (many?) different calling conventions, of which GCC
supports a variety of them.

A calling convention covers these kinds of things:
+ what order are the arguments pushed on the stack...
+ ...or are arguments passed in by registers
+ who is responsible for popping the arguments
+ how is the name decorated

Some calling conventions are particular to a given language or operating
system, hence people might refer to "the Pascal calling convention", or "the
Windows calling convention", or the "SPARC ABI".

GCC uses the calling convention that is appropriate for the platform
(operating system + language).  Sometimes you need finer control over the
calling convention used, rather than use the default -- that's where the
__attribute__ facilities come into play.

Here's the GCC online documentation on the topic (the information is
scattered throughout the HTML page):
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Function-Attributes.html

HTH,
--Eljay


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