Sign in to follow this  
Sami Vuorela

namespace horrors in scriptstdstring addon

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this