Advertisement Jump to content
Sign in to follow this  
Fish Fishes

[C++] Put a macro into a namespace

This topic is 4908 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

Advertisement
No, that's absolutely impossible. Macros are handled before the compiler ever sees the code. That's why they are called preprocessor macros.

Depending on what you really want, function templates may be what you need.

Please provide details.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I don't think the preprocessor understands namespaces. Thus, I don't think it's possible.

Share this post


Link to post
Share on other sites
You cannot. Macros are handled by the preprocessor, and do not follow namespaces or scope. Depending on what kind of macro you are writing, however, you could replace it with a const variable or a typedef, which can be put in a namespace.


jfl.

Share this post


Link to post
Share on other sites
You can always get around it by having a naming standard. Say all macros in the standard namespace gets named STD_NAMEOFMACRO etc. Templates will solve most problems much better than macros though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!