Function arguments

From: Amit Sharma (sharma.am_at_gmail.com)
Date: 09/30/04


Date: 30 Sep 2004 05:56:31 -0700

Hi,
    I wanted to know when we call function with argument, Does the
arguments stored in stack always or it compiler specific and could be
stored in queue

e.g. Does this program's output depends upon the compiler specific or
always would be b a

#include<stdio.h>

        int a()
        {
          printf("a\t");
          return 0;
        }
        int b()
        {
          printf("b\t");
          return 0;
        }
        void c(int a,int b)
        {
        }
int main()
        {
          c(a(),b());
                  return 1;
        }

Thanks,
Amit



Relevant Pages

  • Re: Direction in which the process stack grows
    ... >> int main ... > would force the compiler to create local variables in the same ... > sequence on the stack as you define them in the source code. ... > with gcc and either without optimization or inlining explicitely ...
    (comp.unix.programmer)
  • Re: calling convention stdcalll and cdecl call
    ... the compiler can somehow figure out how the function accesses its parameters, it can figure out how many there are, and pop the stack correctly without any additional information from the caller. ... int find{ ... This is similar to how it must take some action for a __stdcall member function, ...
    (microsoft.public.vc.language)
  • Re: where do the automatic variables go ?
    ... and bss segments etc...but there is notthing like stack and heap ... Stack variables are implied by the compiler (the compiler generates code ... int foo ...
    (comp.os.linux.misc)
  • Re: Do buffers always start with the lowest memory address being the first element?
    ... > The C standard does not assume a downward-growing stack, ... > an upward-growing stack. ... C allows but does not require that the array produced ... > machine depends on both the C compiler and the machine. ...
    (comp.lang.c)
  • Re: Value Types and Reference Types
    ... the compiler doesn't have a list of them. ... So your saying that an int is not special? ... put it on the stack". ... Int32 x; are pretty much identical except for speed/memory issues. ...
    (microsoft.public.dotnet.languages.csharp)