Advertisement

namespace horrors in scriptstdstring addon

Started by September 24, 2015 05:49 PM
1 comment, last by WitchLord 9 years, 2 months ago

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

Thanks. I'll have it fixed.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Fixed in revision 2233

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement