• Advertisement

Archived

This topic is now archived and is closed to further replies.

Complex Macros

This topic is 5456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


  
#define MAKENEW(x) #define x SOMETHING_ELSE
  
Is there any way to accomplish what I''m trying to do here? ______________________________ And the Phoenix shall rise from the ashes... --Thunder_Hawk -- ¦þ ______________________________

Share this post


Link to post
Share on other sites
Advertisement
Nope.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Macros cannot contain other preprocessor directives ( beside the ''stringizing'' # and the ''token pasting'' ## ).


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites
Interesting...back to the drawing board I guess
BTW, this is nothing important I''m just kind of tossing around ideas on things I might do, and this seemed like something neat to try out.

Share this post


Link to post
Share on other sites
on presumption that you wanted to transform x before it got to the first #define, why not just transform it in the define ?

Share this post


Link to post
Share on other sites
I think that you are trying to declare variables using names dependant on runtime data (??). If it so, i guess that a dictionary implementation (maybe a hash table if you are interested on performance and not memory) would be a better solution. Also defines work at compile time so if your syntax weren''t incorrect it would have been the same to use #define y SOMETHING_ELSE and MAKENEW (y)

Share this post


Link to post
Share on other sites
quote:
Original post by hewhay
Also defines work at compile time so if your syntax weren''t incorrect it would have been the same to use #define y SOMETHING_ELSE and MAKENEW (y)


Actually, #define operate before compile-time. That''s why they are called preprocessor macros, and why they let you do things without any language checking. That''s also why preprocessor macros do not respect scope, types ...


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites

  • Advertisement