Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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) {\
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.