Skip to main content
gamedev.net
🔒 Locked

add on std::string

Started by Rain Dog Nov 2, 2004 at 6:26 PM 6 replies 1.8k views
Original Post
Rain Dog
Rain Dog
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.
kaysik
kaysik
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
Rain Dog
Rain Dog
I am using VS.NET 2003
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
Rain Dog
Rain Dog
Yes, that is what i have done. I have wrapper functions. It just seems much nicer to not have them.
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
Deyja
Deyja
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.