add on std::string

Started by
6 comments, last by Deyja 19 years, 5 months ago
I am unable to compile the code dealing with the overloaded operators.

	//r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL,       "bool f(const string &, const string &)", asFUNCTIONPR(operator==, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 );

	r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL,    "bool f(const string &, const string &)", asFUNCTIONPR(operator!=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 );
	r = engine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL,      "bool f(const string &, const string &)", asFUNCTIONPR(operator<=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 );
	r = engine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL,      "bool f(const string &, const string &)", asFUNCTIONPR(operator>=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 );
	r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN,    "bool f(const string &, const string &)", asFUNCTIONPR(operator <, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 );
	r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const string &, const string &)", asFUNCTIONPR(operator >, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 );
	r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD,         "string f(const string &, const string &)", asFUNCTIONPR(operator +, (const string &, const string &), string), asCALL_CDECL); assert( r >= 0 );

gives me the following error: c:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\TestingDDX\ASRegisterVector.cpp(415): fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information It occurs for each of the above lines of code.
Advertisement
download the latest VC6 service pack (think its 6) and it should fix your problem. If its the same error i had its a bug in the compiler not in AS.

Easily found HERE
I am using VS.NET 2003
lol - its not that then :P
This is obviously a bug in MSVC.NET 2003. If there is no patch available, then you will have to try to find some workaround.

Perhaps it works if you write some wrapper functions for the operators? Example:

string Concatenate(const string &a, const string &b)
{
return a+b;
}

r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string &, const string &)", asFUNCTION(Concatenate), asCALL_CDECL); assert( r >= 0 );

Or maybe it is sufficient to use the namespace prefix std:: on the string type?

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

Yes, that is what i have done. I have wrapper functions. It just seems much nicer to not have them.
I agree with you. However, Microsoft doesn't always do so [wink].

I hope they fix the problem in a future patch.

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 used to happen quite a bit in MSVC6.0 with partial specilization of member templates. I'd suspect microsoft still hasn't gotten that right, and the compiler can't resolve the pointers to template functions.

This topic is closed to new replies.

Advertisement