Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Indefinite Number of Parameters

7 views
Skip to first unread message

Zeljko Knezevic

unread,
Jun 5, 2002, 4:38:31 PM6/5/02
to
Hi,
Consider the next function:
int f(...) {
// function body
return 1;
}

Is there any way to determine number of parameters sent to this specific function?


Thanks.
Zeljko


Homer Meyer

unread,
Jun 5, 2002, 4:54:52 PM6/5/02
to

"Zeljko Knezevic" <zeljkok...@hotmail.com> wrote in message
news:adlt10$a2u$1...@bagan.srce.hr...

There might be an implementation specific way, but there is no way available
within standard C++.

Ron Natalie

unread,
Jun 5, 2002, 5:23:20 PM6/5/02
to

Not unless you cut pin 9 on chip E11 on your M8138 card.

It's incumbant on the programmer to know (or figure out) what
arguments are passed and their type. Putting a NULL or something
at the end is a good way.

josh

unread,
Jun 5, 2002, 4:05:14 PM6/5/02
to

Maybe with vararg? Not that I've ever tried...

Victor Bazarov

unread,
Jun 5, 2002, 9:08:19 PM6/5/02
to
"josh" <jo...@xtreme.net> wrote...


It might not be a bad idea to try. However, you'll see that
there is no way to determine how many arguments have been passed
unless it's not indicated in the parameters themselves (e.g. the
number of formatting specifications in the string, the first
argument of printf, defines the number of arguments following the
string).

Victor
--
Please remove capital A's from my address when replying by mail


josh

unread,
Jun 5, 2002, 6:33:09 PM6/5/02
to
On Thu, 06 Jun 2002 01:08:19 GMT, "Victor Bazarov"
<vAba...@dAnai.com> wrote:
> "josh" <jo...@xtreme.net> wrote...

> > Maybe with vararg? Not that I've ever tried...
>
> It might not be a bad idea to try. However, you'll see that
> there is no way to determine how many arguments have been
> passed unless it's not indicated in the parameters themselves
> (e.g. the number of formatting specifications in the string,
> the first argument of printf, defines the number of arguments
> following the string).
Yeah. I've used it a couple of times -- on something printf-
like... Actually, I don't know how it works, could be
interesting to investigate sometime.

AV

unread,
Jun 6, 2002, 4:19:59 AM6/6/02
to
No way. There's no way for a function to know how many parameters were put
on the stack, if they were put in a reversed order (like C calling
convention). Not even if you use assembler.


Zeljko Knezevic

unread,
Jun 6, 2002, 2:22:50 PM6/6/02
to
| No way.

Yes, I thought so....
Thanks to all who've replied.

Zeljko


0 new messages