0

Is there a way to insert preprocessor macro using another preprocessor macro?

Can I do something like, for instance

    #define INSERT_MACRO(x) {#ifdef MYFLAG x; #endif}

so that when I write

    INSERT_MACRO(foo(););

it is converted to

    #ifdef MYFLAG
    foo();
    #endif

? Thanks!

1 Answer 1

1

You cannot use another preprocessor directive in define. Instead you may consider,

#ifdef MYFLAG
#define INSERT_MACRO(x) x;
#else
#define INSERT_MACRO(x) 
#endif
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.