Nobody
2010-02-28 18:00:59 UTC
I am implementing a callback function for multiple callbacks, but the
callback function does not have a parameter such as a handle or number to
tell which callback the call is for. I have no control over it, so I can't
add my own parameters, so I have to provide different entry points that
calls a centralized routine with a sequence number. So I have functions like
this:
int func0(int para1,int para2) { return func(0,para1,para2);};
int func1(int para1,int para2) { return func(1,para1,para2);};
int func2(int para1,int para2) { return func(2,para1,para2);};
int func3(int para1,int para2) { return func(3,para1,para2);};
...
I plan to use a macro like this to generate the above using the
Token-Pasting Operator (##):
#define paster( n ) int func##n(int para1,int para2) { return
func(##n,para1,para2);}
So, to generate the above, I would use:
paster(0);
paster(1);
paster(2);
paster(3);
...
Is there a way to repeatedly call the macro a fixed number of times?
Something like #while or #for loop? Currently, I am using an Excel sheet to
generate the code. Example:
= "paster(" & A1 & ");"
Cells A1 to Ann contain sequence numbers filled by Edit-->Fill-->Series, so
I only have to do one copy and paste.
I am using VC6 and 2003.
Thank you
callback function does not have a parameter such as a handle or number to
tell which callback the call is for. I have no control over it, so I can't
add my own parameters, so I have to provide different entry points that
calls a centralized routine with a sequence number. So I have functions like
this:
int func0(int para1,int para2) { return func(0,para1,para2);};
int func1(int para1,int para2) { return func(1,para1,para2);};
int func2(int para1,int para2) { return func(2,para1,para2);};
int func3(int para1,int para2) { return func(3,para1,para2);};
...
I plan to use a macro like this to generate the above using the
Token-Pasting Operator (##):
#define paster( n ) int func##n(int para1,int para2) { return
func(##n,para1,para2);}
So, to generate the above, I would use:
paster(0);
paster(1);
paster(2);
paster(3);
...
Is there a way to repeatedly call the macro a fixed number of times?
Something like #while or #for loop? Currently, I am using an Excel sheet to
generate the code. Example:
= "paster(" & A1 & ");"
Cells A1 to Ann contain sequence numbers filled by Edit-->Fill-->Series, so
I only have to do one copy and paste.
I am using VC6 and 2003.
Thank you