This is the mail archive of the 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]

Re: Knowing the number of variable arguments.

On May 29, 2000, Gigi Sullivan <> wrote:

>> On May 29, 2000, Gigi Sullivan <> wrote:

>> > 	This is bad, since I cannot know *when* the list is terminated

>> How about requiring a NULL terminator, as in exec()?

> 	Well, I would avoid using this solution (It's boring for what
> 	I'm doing to put *mandatory* a NULL at the end).

If there's no perfect solution, a boring one will have to do, right? :-)

> 	Nevertheless to say (well, as you know ;)) that this could be
> 	non-portable too (Am I right?) :

Nope.  If you pass a list of pointers, the last of which is NULL, then
you can certainly expect va_arg to work correctly on all platforms, as
long as you tell it each argument is the appropriate pointer type.

> 	Not all pass parameters on the stack (that could grows towards
> 	lower/upper address).

va_arg will take care of this for you.

> Could be this an addendum to the current gcc?

What kind of extension are you thinking of?

Alexandre Oliva    Enjoy Guaranį, see
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{,}   Write to mailing lists, not to me

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