what's the meaning of #define here?

Started by
2 comments, last by ehsan2004 15 years, 8 months ago
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
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.
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.
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.

This topic is closed to new replies.

Advertisement