Archived

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

Thunder_Hawk

Complex Macros

Recommended Posts

Thunder_Hawk    314

  
#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
Fruny    1658
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
Thunder_Hawk    314
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
NickB    146
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
hewhay    122
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
Fruny    1658
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