This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: function call argument count
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: don fisher <dfisher at as dot arizona dot edu>, gcc-help at gcc dot gnu dot org
- Date: Mon, 24 May 2004 07:30:37 -0500
- Subject: Re: function call argument count
- References: <40B11F20.7050603@as.arizona.edu>
Hi Don,
There's not an easy way that is platform agnostic to determine the argument
count. You can do it yourself as a convention:
void MyFunc(int argcount, ...);
Then call it with the explicit argument count, via:
int a=1, b=2, c=3;
MyFunc(3, a, b, c);
I recommend that variable arguments be passed in as a std::vector<> or
std::map<> or std::set<> or whatever kind of container is appropriate. Or
better yet, as generic begin() and end() iterators to the aforementioned
containers. By "generic" I mean using templates.
HTH,
--Eljay