M
Michael
Hi all,
I've got a question according the design
of a parameterlist in C. I am going to have
a function taking two parameters.
One is supposed to be used as a flag, which
determines the type of data is needed, which
is passed to the function by the second parameter.
The type of this parameters differs depending on
the flag. E.g.
void doSomething ( int flag, <seeBelow> value)
{
...
switch flag
{
case 1: // I need value to be a double
...
case 2: // Value shoud be an int
...
}
...
}
Since the number of different types is finite,
I wonder what is the best bet to pass the 2nd Parameter
a) Build a struct, containing all possibilities
of which only the needed are set
b) Use a void pointer
c) Something else
Thanks
Michael
I've got a question according the design
of a parameterlist in C. I am going to have
a function taking two parameters.
One is supposed to be used as a flag, which
determines the type of data is needed, which
is passed to the function by the second parameter.
The type of this parameters differs depending on
the flag. E.g.
void doSomething ( int flag, <seeBelow> value)
{
...
switch flag
{
case 1: // I need value to be a double
...
case 2: // Value shoud be an int
...
}
...
}
Since the number of different types is finite,
I wonder what is the best bet to pass the 2nd Parameter
a) Build a struct, containing all possibilities
of which only the needed are set
b) Use a void pointer
c) Something else
Thanks
Michael