Archived

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

Thunder_Hawk

Complex Macros

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
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
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