Hello all!
I am working on a system in C to auto-generate some tables for me based off of some information I have in a header file. I have everything working just fine, except for this part. I need to get it to generate extern prototypes, but only if a callback function is present. If I put NULL in the macro definition in the other file I don't want anything to be generated. An example of what I'm doing is below:
And in Handler_Definitions.h would be:
How can I make it conditional? I haven't found any way to get the preprocessor to make it work the way I want. The macro for Object1 works just fine, but quite obviously Object2 will break things.
I am working on a system in C to auto-generate some tables for me based off of some information I have in a header file. I have everything working just fine, except for this part. I need to get it to generate extern prototypes, but only if a callback function is present. If I put NULL in the macro definition in the other file I don't want anything to be generated. An example of what I'm doing is below:
#define MACRO(NAME, CB) extern void CB( int id, int value );
#include "Handler_Definitions.h"
#undef MACRO
And in Handler_Definitions.h would be:
MACRO(Object1, Generic_Callback)
MACRO(Object2, NULL)
How can I make it conditional? I haven't found any way to get the preprocessor to make it work the way I want. The macro for Object1 works just fine, but quite obviously Object2 will break things.