Sign in to follow this  

gcc compile errors

This topic is 3840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i've nearly finished porting my game over from windows to linux, but have a few more compiler errors which arent an issue under visual studio:
template <class T>
void StateMachine<T>::SetState(int stateType)
{
	vector<T*>::iterator it;
	for (it = mState.begin(); it != mState.end(); ++it)
	{
		if ((*it)->GetType() == stateType)
		{
			SetState(*it);
			return;
		}
	}
}

errors:

/home/bronson/workspace/Project/AirBlimbs/Source/Util/StateMachine.h:56: error: expected `;' before ‘it’
/home/bronson/workspace/Project/AirBlimbs/Source/Util/StateMachine.h:57: error: ‘it’ was not declared in this scope

virtual bool ConvertToNetwork(Packet* data)				
	{
		*data & mPhysModel->GetMessageHandle();
// other code here
}


should be using this one:
template <class T>
Packet& operator &(Packet& packet, T& data)
{
// code
}

the other chandidate:
Packet& operator &(Packet& packet, ServerInfo& data);

error:
/home/bronson/workspace/Project/AirBlimbs/Source/Entity/PhysicsModel.h: In member function ‘virtual bool SyncPhysicsModelMsg::ConvertToNetwork(Packet*)’:
/home/bronson/workspace/Project/AirBlimbs/Source/Entity/PhysicsModel.h:194: error: no match foroperator&’ in ‘* data & ((SyncPhysicsModelMsg*)this)->SyncPhysicsModelMsg::mPhysModel->PhysicsModel::<anonymous>.Entity::<anonymous>.MessageReceiver::GetMessageHandle()’
/home/bronson/workspace/Library/Network/Packet.h:48: note: candidates are: Packet& operator&(Packet&, T&) [with T = MessageReceiverHandle]
/home/bronson/workspace/Library/MasterServer/MasterServer.h:45: note:                 Packet& operator&(Packet&, ServerInfo&)
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/ios_base.h:157: note:                 std::_Ios_Iostate std::operator&(std::_Ios_Iostate, std::_Ios_Iostate)
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/ios_base.h:119: note:                 std::_Ios_Openmode std::operator&(std::_Ios_Openmode, std::_Ios_Openmode)
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/ios_base.h:79: note:                 std::_Ios_Fmtflags std::operator&(std::_Ios_Fmtflags, std::_Ios_Fmtflags)

any help appreciated

Share this post


Link to post
Share on other sites
Quote:
/home/bronson/workspace/Project/AirBlimbs/Source/Util/StateMachine.h:56: error: expected `;' before ‘it’
/home/bronson/workspace/Project/AirBlimbs/Source/Util/StateMachine.h:57: error: ‘it’ was not declared in this scope

When using nested classes and the external one is templated, you must specify that what you worte is a type name, so:

typename vector<T*>::iterator it;

Share this post


Link to post
Share on other sites

This topic is 3840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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