theotyflos
Programmer
Hi all,
I have the following:
/*--- SNIP ---*/
/*--- SNIP ---*/
The question is: Is there a way instead of writing all those #defines
for the arguments (First, Second, etc), to write something like:
and define the arguments like this:
Thanks in advance everyone.
Theophilos.
-----------
There are only 10 kinds of people: Those who understand binary and those who don't.
I have the following:
/*--- SNIP ---*/
Code:
typedef struct Argument_s
{
char *address;
int type;
int length;
} ARGUMENT;
#define Function(F) int F( int ArgCount, ARGUMENT ArgVector[] )
#define First ArgVector[0]
#define First_A First.address
#define First_T First.type
#define First_L First.length
#define Second ArgVector[1]
#define Second_A Second.address
#define Second_T Second.type
#define Second_L Second.length
#define Third ArgVector[2]
#define Third_A Third.address
#define Third_T Third.type
#define Third_L Third.length
Function(One)
{
/* do something with First_A */
/* do something with First_T */
/* do something with First_L */
/* do something with Second_A */
/* do something with Second_T */
/* do something with Second_L */
/* do something with Third_A */
/* do something with Third_T */
/* do something with Third_L */
/* etc etc */
}
#define Apple ArgVector[0]
#define Apple_A Apple.address
#define Apple_T Apple.type
#define Apple_L Apple.length
#define Orange ArgVector[1]
#define Orange_A Orange.address
#define Orange_T Orange.type
#define Orange_L Orange.length
Function(Two)
{
/* do something with Apple_A */
/* do something with Apple_T */
/* do something with Apple_L */
/* do something with Orange_A */
/* do something with Orange_T */
/* do something with Orange_L */
/* etc etc */
}
The question is: Is there a way instead of writing all those #defines
for the arguments (First, Second, etc), to write something like:
Code:
#define Arg(n) #define Arg ArgVector[n] #define Arg##_A Arg.address #define Arg##_T Arg.type #define Arg##_L Arg.length
Code:
Arg First(0)
Arg Second(1)
Arg Third(2)
Function(One)
....
Arg Apple(0)
Arg Orange(1)
Function(Two)
....
Thanks in advance everyone.
Theophilos.
-----------
There are only 10 kinds of people: Those who understand binary and those who don't.