#define MACRO question

Started by
13 comments, last by chollida1 19 years ago
Quote:Original post by chollida1
Really, well that's great!!!

Can you show me how to get this to work with BOOST_PP_CAT.

#ifdef _WIN32
#define message(x) #pragma message "hello"
#else
#define message(x) #warningmessage "hello"
#endif

I also tried putting '#' in my definitions and the BOOST_PP_CAT causes preprocessor to error, Since you say its possible, how do you get '#' in preprocessor macros?? I'd love this feature:)

Bye the way you usually seem like a nice guy/girl, what's up with the terse answer:)

Cheers
CHris


As far as I know, there isn't a real good solution for this. The closest thing I have done to this is something along the lines of

#ifdef ENABLE_DEBUG_FILE_MESSAGES
#define DEBUG_FILE_PRAGMA message( "Parsing " __FILE__ )
#else
#define DEBUG_FILE_PRAGMA
#endif

and then put the following line at the top of my files after the includes

#pragma DEBUG_FILE_PRAGMA

Then I can toggle on the ability to display all header the files that are being parsed when compiling a cpp file.
Advertisement
I tried doynax's solution, and it does seem to work. Adding that middle layer seemed to do the trick.

Thanks.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

Why not do this instead:

const char* ARCHITECTURE_STRING	 = "X86_32";#define TEXT(x) L##xconst wchar_t* ARCHITECTURE_NAME = TEXT(ARCHITECTURE_STRING);


Try to avoid using macros if there's another thing that can replace them (in this case I'm using constant variables).
Quote:Original post by chollida1
I don't believe BOOST_PP_CAT will work for definitions that have '#' in them

CHeers
CHris

I was responding to the OP's example, sorry for any confusion.
--Michael Fawcett
No problem, I was the one who was confused!

Cheers
Chris
CheersChris

This topic is closed to new replies.

Advertisement