Jean
Jean

Reputation: 22695

Macro for a multi line C preprocessor directive

I was trying to create a shorthand for the following code.

#ifdef   TEST_DEF  
#define  MY_TEST_DEF TEST_DEF 
#else
#define  MY_TEST_DEF 120 
#endif

How do I write the above code as a single line macro

SAFE_DEF(TEST_DEF,MY_TEST_DEF,120)

Upvotes: 0

Views: 360

Answers (1)

2501
2501

Reputation: 25752

It is not possible. Every new define must be defined on its own line, and cannot declare a new define in itself.

You will have use the ifdef,else method.

Upvotes: 1

Related Questions