πŸŽ‰ Celebrating 25 Years of GameDev.net! πŸŽ‰

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Registerring Strings

Started by
11 comments, last by lxnyce 18Β years, 11Β months ago
I am trying to test out the new release, but run into trouble registerring variables. It appears to be the following lines. When I run the included projects using msvc 7.1 (2003) it compiles cleanly. When I compile from my project, I get the following error for the lines stated below :
error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'bool (__cdecl *)(const std::string &,const std::string &)'
        None of the functions with this name in scope match the target type
This happens if I use the AC string or the std string (since they both use the same piece of code here). Anybody have a clue whats going on?

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 );
Advertisement
This seems to work, so I am using it for now.

static bool StringEqual(const String& s1, const String& s2)			{ return operator==(s1, s2); }static bool StringNotEqual(const String& s1, const String& s2)		{ return operator!=(s1, s2); }static bool StringLeEqual(const String& s1, const String& s2)		{ return operator<=(s1, s2); }static bool StringGeEqual(const String& s1, const String& s2)		{ return operator>=(s1, s2); }static bool StringLessThan(const String& s1, const String& s2)		{ return operator<(s1, s2); }static bool StringGreaterThan(const String& s1, const String& s2)	{ return operator>(s1, s2); }


// Register the global operator overloads// Note: We can use std::string's methods directly because the// internal std::string is placed at the beginning of the classr = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL,       "bool f(const string ∈, const string ∈)", asFUNCTIONPR(StringEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 );r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL,    "bool f(const string ∈, const string ∈)", asFUNCTIONPR(StringNotEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 );r = engine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL,      "bool f(const string ∈, const string ∈)", asFUNCTIONPR(StringLeEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 );r = engine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL,      "bool f(const string ∈, const string ∈)", asFUNCTIONPR(StringGeEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 );r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN,    "bool f(const string ∈, const string ∈)", asFUNCTIONPR(StringLessThan, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 );r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const string ∈, const string ∈)", asFUNCTIONPR(StringGreaterThan, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 );
It would seem that for some reason the C++ compiler cannot find the comparison functions for std::string.

Maybe their declaration have changed since MSVC6.0? Or maybe you are using some configurations that make the declarations invalid? Is the type String (with capital S) that you used in your solution the same as std::string, maybe this type is somehow conflicting with the declarations in <string>?

Take a look at the include file <string> and see if you can determine what the function signatures are for the string comparison operators.

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

Sorry, the captial "String" declaration was a left over from a copy and paste job. I compile your supplied projects cleanly, so I am assuming that it is a compiler configuration error. The only thing I can think of thats funny though, is probably the use of precompiled headers.

The string class I use is actually something completely different (like aCString). I just typedef String because I prefer typing that. I don't think it should be causing the compilation issue. I supplied it below for reference if you like though.

// string standard header#pragma once#ifndef _STRING_#define _STRING_#include <istream>#pragma pack(push,8)#pragma warning(push,3) #pragma warning(disable: 4189)_STD_BEGIN		// basic_string TEMPLATE OPERATORStemplate<class _Elem,	class _Traits,	class _Alloc> inline	basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// return string + string	return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);	}template<class _Elem,	class _Traits,	class _Alloc> inline	basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(		const _Elem *_Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// return NTCS + string	return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);	}template<class _Elem,	class _Traits,	class _Alloc> inline	basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(		const _Elem _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// return character + string	return (basic_string<_Elem, _Traits, _Alloc>(1, _Left) += _Right);	}template<class _Elem,	class _Traits,	class _Alloc> inline	basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem *_Right)	{	// return string + NTCS	return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);	}template<class _Elem,	class _Traits,	class _Alloc> inline	basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem _Right)	{	// return string + character	return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator==(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test for string equality	return (_Left.compare(_Right) == 0);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator==(		const _Elem * _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test for NTCS vs. string equality	return (_Right.compare(_Left) == 0);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator==(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem *_Right)	{	// test for string vs. NTCS equality	return (_Left.compare(_Right) == 0);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator!=(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test for string inequality	return (!(_Left == _Right));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator!=(		const _Elem *_Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test for NTCS vs. string inequality	return (!(_Left == _Right));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator!=(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem *_Right)	{	// test for string vs. NTCS inequality	return (!(_Left == _Right));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator<(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if string < string	return (_Left.compare(_Right) < 0);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator<(		const _Elem * _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if NTCS < string	return (_Right.compare(_Left) > 0);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator<(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem *_Right)	{	// test if string < NTCS	return (_Left.compare(_Right) < 0);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator>(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if string > string	return (_Right < _Left);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator>(		const _Elem * _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if NTCS > string	return (_Right < _Left);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator>(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem *_Right)	{	// test if string > NTCS	return (_Right < _Left);	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator<=(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if string <= string	return (!(_Right < _Left));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator<=(		const _Elem * _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if NTCS <= string	return (!(_Right < _Left));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator<=(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem *_Right)	{	// test if string <= NTCS	return (!(_Right < _Left));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator>=(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if string >= string	return (!(_Left < _Right));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator>=(		const _Elem * _Left,		const basic_string<_Elem, _Traits, _Alloc>& _Right)	{	// test if NTCS >= string	return (!(_Left < _Right));	}template<class _Elem,	class _Traits,	class _Alloc> inline	bool __cdecl operator>=(		const basic_string<_Elem, _Traits, _Alloc>& _Left,		const _Elem *_Right)	{	// test if string >= NTCS	return (!(_Left < _Right));	} #ifdef _DLL_CPPLIBtemplate class _CRTIMP2 basic_string<char,	char_traits<char>, allocator<char> > __cdecl operator+(		const basic_string<char, char_traits<char>, allocator<char> >&,		const basic_string<char, char_traits<char>, allocator<char> >&);template class _CRTIMP2 basic_string<char,	char_traits<char>, allocator<char> > __cdecl operator+(		const char *,		const basic_string<char, char_traits<char>, allocator<char> >&);template class _CRTIMP2 basic_string<char,	char_traits<char>, allocator<char> > __cdecl operator+(		const char,		const basic_string<char, char_traits<char>, allocator<char> >&);template class _CRTIMP2 basic_string<char,	char_traits<char>, allocator<char> > __cdecl operator+(		const basic_string<char, char_traits<char>, allocator<char> >&,		const char *);template class _CRTIMP2 basic_string<char,	char_traits<char>, allocator<char> > __cdecl operator+(		const basic_string<char, char_traits<char>, allocator<char> >&,		const char);template _CRTIMP2 bool __cdecl operator==(	const basic_string<char, char_traits<char>, allocator<char> >&,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator==(	const char *,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator==(	const basic_string<char, char_traits<char>, allocator<char> >&,	const char *);template _CRTIMP2 bool __cdecl operator!=(	const basic_string<char, char_traits<char>, allocator<char> >&,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator!=(	const char *,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator!=(	const basic_string<char, char_traits<char>, allocator<char> >&,	const char *);template _CRTIMP2 bool __cdecl operator<(	const basic_string<char, char_traits<char>, allocator<char> >&,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator<(	const char *,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator<(	const basic_string<char, char_traits<char>, allocator<char> >&,	const char *);template _CRTIMP2 bool __cdecl operator>(	const basic_string<char, char_traits<char>, allocator<char> >&,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator>(	const char *,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator>(	const basic_string<char, char_traits<char>, allocator<char> >&,	const char *);template _CRTIMP2 bool __cdecl operator<=(	const basic_string<char, char_traits<char>, allocator<char> >&,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator<=(	const char *,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator<=(	const basic_string<char, char_traits<char>, allocator<char> >&,	const char *);template _CRTIMP2 bool __cdecl operator>=(	const basic_string<char, char_traits<char>, allocator<char> >&,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator>=(	const char *,	const basic_string<char, char_traits<char>, allocator<char> >&);template _CRTIMP2 bool __cdecl operator>=(	const basic_string<char, char_traits<char>, allocator<char> >&,	const char *);template class _CRTIMP2 basic_string<wchar_t,	char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(		const basic_string<wchar_t, char_traits<wchar_t>,			allocator<wchar_t> >&,		const basic_string<wchar_t, char_traits<wchar_t>,			allocator<wchar_t> >&);template class _CRTIMP2 basic_string<wchar_t,	char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(		const wchar_t *,		const basic_string<wchar_t, char_traits<wchar_t>,			allocator<wchar_t> >&);template class _CRTIMP2 basic_string<wchar_t,	char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(		const wchar_t,		const basic_string<wchar_t, char_traits<wchar_t>,			allocator<wchar_t> >&);template class _CRTIMP2 basic_string<wchar_t,	char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(		const basic_string<wchar_t, char_traits<wchar_t>,			allocator<wchar_t> >&,		const wchar_t *);template class _CRTIMP2 basic_string<wchar_t,	char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(		const basic_string<wchar_t, char_traits<wchar_t>,			allocator<wchar_t> >&,		const wchar_t);template _CRTIMP2 bool __cdecl operator==(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator==(	const wchar_t *,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator==(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const wchar_t *);template _CRTIMP2 bool __cdecl operator!=(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator!=(	const wchar_t *,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator!=(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const wchar_t *);template _CRTIMP2 bool __cdecl operator<(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator<(	const wchar_t *,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator<(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const wchar_t *);template _CRTIMP2 bool __cdecl operator>(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator>(	const wchar_t *,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator>(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const wchar_t *);template _CRTIMP2 bool __cdecl operator<=(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator<=(	const wchar_t *,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator<=(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const wchar_t *);template _CRTIMP2 bool __cdecl operator>=(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator>=(	const wchar_t *,	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template _CRTIMP2 bool __cdecl operator>=(	const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,	const wchar_t *); #endif /* _DLL_CPPLIB */		// basic_string INSERTERS AND EXTRACTORStemplate<class _Elem,	class _Traits,	class _Alloc> inline	basic_istream<_Elem, _Traits>& __cdecl operator>>(		basic_istream<_Elem, _Traits>& _Istr,		basic_string<_Elem, _Traits, _Alloc>& _Str)	{	// extract a string	typedef ctype<_Elem> _Ctype;	typedef basic_istream<_Elem, _Traits> _Myis;	typedef basic_string<_Elem, _Traits, _Alloc> _Mystr;	typedef typename _Mystr::size_type _Mysizt;	ios_base::iostate _State = ios_base::goodbit;	bool _Changed = false;	const typename _Myis::sentry _Ok(_Istr);	if (_Ok)		{	// state okay, extract characters		const _Ctype& _Ctype_fac = _USE(_Istr.getloc(), _Ctype);		_Str.erase();		_TRY_IO_BEGIN		_Mysizt _Size = 0 < _Istr.width()			&& (_Mysizt)_Istr.width() < _Str.max_size()				? (_Mysizt)_Istr.width() : _Str.max_size();		typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc();		for (; 0 < _Size; --_Size, _Meta = _Istr.rdbuf()->snextc())			if(_Traits::eq_int_type(_Traits::eof(), _Meta))				{	// end of file, quit				_State |= ios_base::eofbit;				break;				}			else if (_Ctype_fac.is(_Ctype::space,				_Traits::to_char_type(_Meta)))				break;	// whitespace, quit			else				{	// add character to string				_Str.append(1, _Traits::to_char_type(_Meta));				_Changed = true;				}		_CATCH_IO_(_Istr)		}	_Istr.width(0);	if (!_Changed)		_State |= ios_base::failbit;	_Istr.setstate(_State);	return (_Istr);	}template<class _Elem,	class _Traits,	class _Alloc> inline	basic_istream<_Elem, _Traits>& __cdecl getline(		basic_istream<_Elem, _Traits>& _Istr,		basic_string<_Elem, _Traits, _Alloc>& _Str,		const _Elem _Delim)	{	// get characters into string, discard delimiter	typedef basic_istream<_Elem, _Traits> _Myis;	ios_base::iostate _State = ios_base::goodbit;	bool _Changed = false;	const typename _Myis::sentry _Ok(_Istr, true);	if (_Ok)		{	// state okay, extract characters		_TRY_IO_BEGIN		_Str.erase();		const typename _Traits::int_type _Metadelim =			_Traits::to_int_type(_Delim);		typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc();		for (; ; _Meta = _Istr.rdbuf()->snextc())			if (_Traits::eq_int_type(_Traits::eof(), _Meta))				{	// end of file, quit				_State |= ios_base::eofbit;				break;				}			else if (_Traits::eq_int_type(_Meta, _Metadelim))				{	// got a delimiter, discard it and quit				_Changed = true;				_Istr.rdbuf()->sbumpc();				break;				}			else if (_Str.max_size() <= _Str.size())				{	// string too large, quit				_State |= ios_base::failbit;				break;				}			else				{	// got a character, add it to string				_Str += _Traits::to_char_type(_Meta);				_Changed = true;				}		_CATCH_IO_(_Istr)		}	if (!_Changed)		_State |= ios_base::failbit;	_Istr.setstate(_State);	return (_Istr);	}template<class _Elem,	class _Traits,	class _Alloc> inline	basic_istream<_Elem, _Traits>& __cdecl getline(		basic_istream<_Elem, _Traits>& _Istr,		basic_string<_Elem, _Traits, _Alloc>& _Str)	{	// get characters into string, discard newline	return (getline(_Istr, _Str, _Istr.widen('\n')));	}template<class _Elem,	class _Traits,	class _Alloc> inline	basic_ostream<_Elem, _Traits>& __cdecl operator<<(		basic_ostream<_Elem, _Traits>& _Ostr,		const basic_string<_Elem, _Traits, _Alloc>& _Str)	{	// insert a string	typedef basic_ostream<_Elem, _Traits> _Myos;	typedef basic_string<_Elem, _Traits, _Alloc> _Mystr;	typedef typename _Mystr::size_type _Mysizt;	ios_base::iostate _State = ios_base::goodbit;	_Mysizt _Size = _Str.size();	_Mysizt _Pad = _Ostr.width() <= 0 || (_Mysizt)_Ostr.width() <= _Size			? 0 : (_Mysizt)_Ostr.width() - _Size;	const typename _Myos::sentry _Ok(_Ostr);	if (!_Ok)		_State |= ios_base::badbit;	else		{	// state okay, insert characters	_TRY_IO_BEGIN		if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left)			for (; 0 < _Pad; --_Pad)	// pad on left				if (_Traits::eq_int_type(_Traits::eof(),					_Ostr.rdbuf()->sputc(_Ostr.fill())))					{	// insertion failed, quit					_State |= ios_base::badbit;					break;					}		if (_State == ios_base::goodbit)			for (_Mysizt _Count = 0; _Count < _Size; ++_Count)				if (_Traits::eq_int_type(_Traits::eof(),					_Ostr.rdbuf()->sputc(_Str[_Count])))					{	// insertion failed, quit					_State |= ios_base::badbit;					break;					}		if (_State == ios_base::goodbit)			for (; 0 < _Pad; --_Pad)	// pad on right				if (_Traits::eq_int_type(_Traits::eof(),					_Ostr.rdbuf()->sputc(_Ostr.fill())))					{	// insertion failed, quit					_State |= ios_base::badbit;					break;					}		_Ostr.width(0);		_CATCH_IO_(_Ostr)		}	_Ostr.setstate(_State);	return (_Ostr);	} #ifdef _DLL_CPPLIBtemplate class _CRTIMP2 basic_istream<char,	char_traits<char> >& __cdecl operator>>(		basic_istream<char, char_traits<char> >&,		basic_string<char, char_traits<char>, allocator<char> >&);template class _CRTIMP2 basic_istream<char,	char_traits<char> >& __cdecl getline(		basic_istream<char, char_traits<char> >&,		basic_string<char, char_traits<char>, allocator<char> >&);template class _CRTIMP2 basic_istream<char,	char_traits<char> >& __cdecl getline(		basic_istream<char, char_traits<char> >&,		basic_string<char, char_traits<char>, allocator<char> >&,		const char);template class _CRTIMP2 basic_ostream<char,	char_traits<char> >& __cdecl operator<<(		basic_ostream<char, char_traits<char> >&,		const basic_string<char, char_traits<char>, allocator<char> >&);template class _CRTIMP2 basic_istream<wchar_t,	char_traits<wchar_t> >& __cdecl operator>>(		basic_istream<wchar_t, char_traits<wchar_t> >&,		basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template class _CRTIMP2 basic_istream<wchar_t,	char_traits<wchar_t> >& __cdecl getline(		basic_istream<wchar_t, char_traits<wchar_t> >&,		basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);template class _CRTIMP2 basic_istream<wchar_t,	char_traits<wchar_t> >& __cdecl getline(		basic_istream<wchar_t, char_traits<wchar_t> >&,		basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,		const wchar_t);template class _CRTIMP2 basic_ostream<wchar_t,	char_traits<wchar_t> >& __cdecl operator<<(		basic_ostream<wchar_t, char_traits<wchar_t> >&,		const basic_string<wchar_t, char_traits<wchar_t>,			allocator<wchar_t> >&); #endif /* _DLL_CPPLIB */_STD_END #pragma warning(default: 4189)#pragma warning(pop)#pragma pack(pop)#endif /* _STRING *//* * Copyright (c) 1992-2002 by P.J. Plauger.  ALL RIGHTS RESERVED. * Consult your license regarding permissions and restrictions. V3.13:0009 */
It could be the precompiled headers. Though I rather think it is something else. Are you defining the _STRING_ preprocessor command in your own string file? If you do, and include <string> afterwards, then the std::string won't be declared.

From what I can determine from the code you pasted, the std::string implementation hasn't changed in any way that should stop it from working. I didn't really think it would either since, others are successfully using it with MSVC7.1.

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

MSVC7.1 is old news. I'm using your std::string binding code as is in MSVC8.0, from both versions 1.10.1d and 2.3.0.

OP; you say you are using your own custom string class. Can you post it's source too? Digging through standard library source is not all that fun. Precompiled headers could cause it, but MSVC should have recompiled them when it detected changes. Try doing a full re-build.
Also - I'd suspect the problem has to do with template overload resolution.

Using VC 7.1 (2003), the scriptstring.cpp/h code gave me an INTERNAL COMPILER ERROR even, on this line:

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

I can confirm that lxnyce's workaround compiles, so thanks for that!
I ran into the INTERNAL COMPILER ERROR issue as well, but only when trying to resolve the std:string issue, so I didn't mention it.

Deyja, the code to the string class is not that easy to disect, and if I could I would post it. It is basically wxString from wxWidgets though.
Quote: From what I can determine from the code you pasted, the std::string implementation hasn't changed in any way that should stop it from working. I didn't really think it would either since, others are successfully using it with MSVC7.1.

I compile cleanly in MSVC 7.1 myself with the supplied solutions. That means its almost definetely a configuration issue, as I haven't changed anything (copy and pasted really). I even use the std string, not my custom version.

Since the solution I had from an older version worked though, I am just going to stick with that and hope I don't run into this problem again (sweep it under the carpet if you will).

Thanks again for all the help guys.
Quote: Original post by WitchLord
It would seem that for some reason the C++ compiler cannot find the comparison functions for std::string.

Maybe their declaration have changed since MSVC6.0? Or maybe you are using some configurations that make the declarations invalid? Is the type String (with capital S) that you used in your solution the same as std::string, maybe this type is somehow conflicting with the declarations in <string>?

Take a look at the include file <string> and see if you can determine what the function signatures are for the string comparison operators.




I also experience these problems with the STLPort std::string implementation. I would get internal compiler errors on i believe the == operator. I just solved it by making the static functions.

This topic is closed to new replies.

Advertisement