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]

Knowing the number of variable arguments.

Aiee :)


	I'm not sure this is the right mailing list and I search
	a little bit the archive, but didn't find the right answer ...
	so please forgive me :)

	Let consider this simple function prototype:

	func(char, int, ...);

	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?

	I'm saying so, since the argument type (in my .c file) isn't 
	int, but it's a union (or it could be a struct too - but right now
	a union) and as man said, when there are no other argument in 
	the list, va_arg returns random errors. 

	This is bad, since I cannot know *when* the list is terminated
	(and I cannot do like the example showed to me, i.e. using pointer +
	while and switch etc etc).

	I tried to search about some __buitin_*, but I didn't find anything
	to suite my needs.

	Well, I indeed solved the problem, but it's strictly non-portable
	since I played with the saved frame pointer (to know the caller frame
	address) and with the address of the first argument in `func' (even
	if no asm code were used, tho. Still not-portable, I guess due to
	different calling convention. The CPU is an Intel x86).

	So I was wondering if someone could point me out a solution
	like some magic macro, such as GIMME_ARGS_NUMBER :)

Thx for all.

bye bye

				-- gg sullivan


I apologize for my bad english.

Lorenzo Cavallaro	`Gigi Sullivan' <>

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

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