Jump to content
  • Advertisement
Sign in to follow this  
ehsan2004

what's the meaning of #define here?

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

Hello there, What's the meaning of #define END_ENGINE_NAMESPACE below: #define DECLARE_ENGINE_NAMESPACE namespace bbe { #define END_ENGINE_NAMESPACE } I know that DECLARE_ENGINE_NAMESPACE would be replaced wth namespace bbe { #define END_ENGINE_NAMESPACE } everytime we use DECLARE_ENGINE_NAMESPACE. The author has used the following code inside the files: DECLARE_ENGINE_NAMESPACE //He has written his code here, for example he has defined a class END_ENGINE_NAMESPACE Is it equivalent with: namespace bbe { //He has written his code here, for example he has defined a class } But if yes, how #define END_ENGINE_NAMESPACE cause it here? Regards, Ehsan

Share this post


Link to post
Share on other sites
Advertisement
Those two #define statements should be on separate lines.

As you've deduced, all these macros are doing is opening and closing a namespace scope. Although justifiable in some niche circumstances -- such as needing to compile as C, which I don't believe to be the case here -- this is, in general, an extremely poor and improper use of macros, so I don't recommend you follow the example set by the author of this code.

Share this post


Link to post
Share on other sites
I have also seen it used for namespace versioning (i.e. the Fbx SDK does this). Basically it just generates,

namespace FBX_SDK_20_11_2006 {

namespace FBX_SDK_20_06_2008 {

etc. But i agree with jpetrie, it's a sucky way to program.

Share this post


Link to post
Share on other sites
thanks,
BTW, this code is from the book "Ultimate 3D game engine design and architecture" by Allen Sherrod. He has written a cross platform code in this book.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!