I'm trying to use C stdarg.h lib, with a generic type.
The type int, is my generic type > to understand it, please, hold reading.
So, my problem is:
I have a function that accept variable number of arguments. like
void function (int paramN, ...);
In my program, there are no way to know, which is the type of variable arguments, it can be a char, an array, an int, an short, an function point, etc... like
function (paramN, "Hey, I'm a string", 1, function_pint, array, -1); // -1 is a sentinel.
So, I think that, an int, is 32bits, in a x86(32bits) system, this will hold all address of memory. So, if I get all arguments with a int, it will not be a problem, for example, "Hey, I'm a string" the address of this string, fit normally in a 32bits variable, so, i need only to make a cast.
Im right?
Can I do it?
Note: I don't want to make my function like printf (this solution, don't fit in this case ok?)
Thanks for all answer.
And sorry for my bad english.
See Question&Answers more detail:
os