Knowing the number of variable arguments.

Gigi Sullivan sullivan@sikurezza.org
Sun May 28 18:27:00 GMT 2000


Aiee :)

	Hello!

> On May 29, 2000, Gigi Sullivan <sullivan@sikurezza.org> wrote:
> 
> > 	Well, I know that using va_start/va_arg and va_end I can
> > 	scan all the variable arguments list, but what if I'd like
> > 	to know the *number* of the variable arguments?
> 
> There's no portable way.  That's why functions with variable number of
> arguments require at least one argument: so that you can pass in some
> clue about the other arguments.

	Yes, I see.

> 
> > 	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).

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

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

	What do you advice to me? (maybe the former solution is better than the
	latter one).

	Anyway THX :))

bye bye

				-- gg sullivan

P.S.

Could be this an addendum to the current gcc? (addendum to stdarg.h I mean)
This is not portable, but it's possible to do as stdarg.h does: #ifdef :)

-- 
Lorenzo Cavallaro	`Gigi Sullivan' <sullivan@sikurezza.org>

Until I loved, life had no beauty;
I did not know I lived until I had loved. (Theodor Korner)


More information about the Gcc-help mailing list