Jump to content
  • Advertisement
Sign in to follow this  
Sami Vuorela

namespace horrors in scriptstdstring addon

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

The scriptstdstring.cpp file in AS version 2.30.2 has this code after the first includes:

 

using namespace std;


BEGIN_AS_NAMESPACE


// This macro is used to avoid warnings about unused variables.
// Usually where the variables are only used in debug mode.
#define UNUSED_VAR(x) (void)(x)


#if AS_USE_STRINGPOOL == 1


#ifdef AS_CAN_USE_CPP11
  // The string pool doesn't need to keep a specific order in the
  // pool, so the unordered_map is faster than the ordinary map
  #include <unordered_map>  // std::unordered_map
  typedef unordered_map<const char *, string> map_t;
#else
  #include <map>      // std::map
  typedef map<const char *, string> map_t;
#endif

.

If the preprocessor definition AS_USE_NAMESPACE is defined and BEGIN_AS_NAMESPACE opens the Angelscript namespace, the includes for map or unordered_map after the namespace will explode horribly and give hundreds of errors about the gruesome internals of the standard library.

 

If I move the includes above the BEGIN_AS_NAMESPACE line, all is well.

 

 

No explosions:

 

using namespace std;




#if AS_USE_STRINGPOOL == 1
  #ifdef AS_CAN_USE_CPP11
    // The string pool doesn't need to keep a specific order in the
    // pool, so the unordered_map is faster than the ordinary map
    #include <unordered_map>  // std::unordered_map
  #else
    #include <map>      // std::map
  #endif
#endif




BEGIN_AS_NAMESPACE




// This macro is used to avoid warnings about unused variables.
// Usually where the variables are only used in debug mode.
#define UNUSED_VAR(x) (void)(x)




#if AS_USE_STRINGPOOL == 1




#ifdef AS_CAN_USE_CPP11
  // The string pool doesn't need to keep a specific order in the
  // pool, so the unordered_map is faster than the ordinary map
  typedef unordered_map<const char *, string> map_t;
#else
  typedef map<const char *, string> map_t;
#endif

 

 

 

 

Edited by Sami Vuorela

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!