I'm trying to write a macro that generates code for an object pool for any given class of objects in C.
I keep getting error: '#' is not followed by a macro parameter
whenever I run the preprocessor
I've tried replacing x##y with:
#define CONCAT1(x, y) x##y
#define CONCAT2(x, y) CONCAT1(x, y)
as this was suggested in a similar question
#define CONCAT1(x, y) x##y
#define CONCAT2(x, y) CONCAT1(x, y)
#define DECLARE_POOL(CLASS, LEVEL1, LEVEL2) {\
\
#define CONCAT2(CLASS, _Pool_Level1) LEVEL1\
#define CONCAT2(CLASS, _Pool_Level2) LEVEL2\
\
CLASS* CONCAT2(CLASS, _Pool)[LEVEL1] = { 0 };\
\
int CONCAT2(CLASS, _Available_Head) = -1;\
int CONCAT2(CLASS, _Available_Tail) = -1;\
\
int CONCAT2(CLASS, _In_Use_Head) = -1;\
int CONCAT2(CLASS, _In_Use_Tail) = -1;\
\
int CONCAT2(CLASS, _Increase_Pool)(int Level1_Address){\
\
}\
\
int CLASS(int Address) {\
\
}\
\
int CONCAT2(CLASS, _Delete)(int Address) {\
\
}\
\
int CONCAT2(CLASS, s)(int Address)\
\
}\
\
int CONCAT2(CLASS, _Save_All)(void)\
\
}\
\
int CONCAT2(CLASS, _Restore_All)(void)\
\
}\
int CONCAT2(CLASS, _Free_All)(void)\
\
}\
}
Expected: Code goes through the preprocessor and gives function prototypes for objects of type "CLASS"
Actual Results:
error: '#' is not followed by a macro parameter
#define DECLARE_POOL(CLASS, LEVEL1, LEVEL2) {\