printf() problem

Tim Dierks dierks at ndmath.UUCP
Sat Apr 29 09:01:01 AEST 1989


>From article <163 at marvin.moncam.co.uk>, by paul at moncam.co.uk (Paul Hudson):
< In article <89Apr26.092233edt.18850 at me.utoronto.ca>, zougas at me.utoronto.ca ("Athanasios(Tom) Zougas") writes:
<> In article <11657 at hodge.UUCP> jdm at hodge.UUCP (jdm) writes:
<> >
<> >    Perhaps someone could explain this printf() phenomena to me.
< ...
<> >        printf("%x %x %x %x\n", getc(fp), getc(fp), getc(fp), getc(fp));
< 
<> C puts its function parameters on the stack in "reverse" order, i.e.
<>  ...
< No. C does not have any order defined for function evaluation. Typically
< compilers derived from pcc or that pass args. purely on the stack will
< push in reverse order, but even this isn't defined. Don't rely on it!

  I understand that the _order_ of evaluation is undefined...  My question
is if the stack-based method of passing arguments, or the order in which
the arguments are passed, is part of the C definition.  The alternative
seems to me to be making all functions that take a variable number of
arguments non-portable.  Is this the case?

Tim Dierks
dierks at darwin.cc.nd.edu



More information about the Comp.lang.c mailing list