Archived

This forum has been archived. Please start a new discussion on GitHub.

Compile gives error C2555

Hello, I was wondering if someone could help me with this.
In VC7.1 I compile and get:
e:\Src\swccg\SWCCG\ICE\include\SWCCG.h(481): error C2555: 'SWCCG::Auth::ice_isA': overriding virtual function return type differs and is not covariant from 'Ice::Object::ice_isA'
e:\Src\swccg\SWCCG\ICE\include\SWCCG.h(481): error C2555: 'SWCCG::Auth::ice_isA': overriding virtual function return type differs and is not covariant from 'Ice::Object::ice_isA'
e:\Src\swccg\SWCCG\ICE\include\SWCCG.h(541): error C2555: 'SWCCG::Game::ice_isA': overriding virtual function return type differs and is not covariant from 'Ice::Object::ice_isA'
e:\Src\swccg\SWCCG\ICE\include\SWCCG.h(541): error C2555: 'SWCCG::Game::ice_isA': overriding virtual function return type differs and is not covariant from 'Ice::Object::ice_isA'
e:\Src\swccg\SWCCG\ICE\include\SWCCG.h(524): error C2555: 'SWCCG::Server::ice_isA': overriding virtual function return type differs and is not covariant from 'Ice::Object::ice_isA'
e:\Src\swccg\SWCCG\ICE\include\SWCCG.h(524): error C2555: 'SWCCG::Server::ice_isA': overriding virtual function return type differs and is not covariant from 'Ice::Object::ice_isA'

The code where the first error points to: (slice2cpp generated SWCCG.h)
class Auth : virtual public ::Ice::Object
{
public:

    virtual bool ice_isA(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) const;
    virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Current& = ::Ice::Current()) const;
    virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current()) const;
    static const ::std::string& ice_staticId();

    virtual ::Ice::Int create(const ::std::string&, const ::std::string&, const ::std::string&, const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
    ::IceInternal::DispatchStatus ___create(::IceInternal::Incoming&, const ::Ice::Current&);

    virtual ::SWCCG::Player login(const ::std::string&, const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
    ::IceInternal::DispatchStatus ___login(::IceInternal::Incoming&, const ::Ice::Current&);

    virtual ::SWCCG::Player get(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
    ::IceInternal::DispatchStatus ___get(::IceInternal::Incoming&, const ::Ice::Current&);

    virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);

    virtual void __write(::IceInternal::BasicStream*) const;
    virtual void __read(::IceInternal::BasicStream*, bool);
    virtual void __write(const ::Ice::OutputStreamPtr&) const;
    virtual void __read(const ::Ice::InputStreamPtr&, bool);
}; // <--- Error points here!

I upgraded to 2.1.2 (was on 2.0.0 first..) but that didn't help, so maybe I'm doing something wrong?
Searching the forum and net didn't help much. Any ideas?

Thanks in advance,
Alex

Comments

  • benoit
    benoit Rennes, France
    Hi Alex,

    Please see [thread=1697]this thread[/thread] if you want us to help you figure out this problem.

    Thanks,

    Benoit.
  • Okay, voila.
  • bernard
    bernard Jupiter, FL
    Looks like you're defining 'bool' to something else.
    Do you get any error while compiling the .cpp files generated by slice2cpp?

    Cheers,
    Bernard
  • I did "slice2cpp --impl --ice --output-dir c:\bla c:\bla\SWCCG.ice" and after adding a main() (just cout'ed something), it compiled (and ran) fine.

    I don't have any funcs in my .ice that return booleans, isn't ice_isA a helperclass? (to check what type an object is)

    Thanks.
  • matthew
    matthew NL, Canada
    What are you compiling that gives you that error? Is it your own code? If so, then find out what is re-defining bool and remove that badness :)
  • The error occurs in slice generated code (see the second code-frame in the first post, the comment "Error points here" at the bottom). I'm sure it's my own fault, but I can't seem to find the cause..

    Thanks,
    Alex
  • The error occurs in a slice-generated header file (SWCCG.h). Which .cpp file that includes this header file is causing the error?
  • It occurs when compiling client.cpp, which includes client.h, which in turn includes SWCCG.h.
    Here's client.h
    #ifndef SWCCG_CLIENT_H
    #define SWCCG_CLIENT_H
    
    #include <Ice/Ice.h>
    #include "SWCCG.h"
    
    #include "console.h"
    
    #include <string>
    #include <vector>
    
    #ifndef UINT
    #define UINT
    typedef unsigned int uint;
    #endif
    
    using namespace Ice;
    
    class client : public handler {
    
    protected:
    	int running;
    	console *screen;
    	Ice::CommunicatorPtr ic;
    	
    public:
    	SWCCG::Player player;
    	SWCCG::ServerPrx server;
    
    	inline client() : running(1), server(NULL) {
    		screen = new console(this);
    		player.id = 0;
    		player.credits = 0;
    	}
    	inline client(Ice::CommunicatorPtr _ic) : running(1), ic(_ic), server(NULL) { 
    		screen = new console(this);
    		player.id = 0;
    		player.credits = 0;
    	}
    	inline virtual ~client() {}
    
    	void join(SWCCG::ServerPrx);
    	void setAuth(SWCCG::AuthPrx);
    	void disconnect();
    
    	virtual int run();
    
    	int parse(std::string);
    
    	int help(std::vector<std::string>);
    	int connect(std::vector<std::string>);
    	int create(std::vector<std::string>);
    	int login(std::vector<std::string>);
    	int list(std::vector<std::string>);
    	int quit(std::vector<std::string>);
    	int heartbeat(std::vector<std::string>);
    	int invite(std::vector<std::string>);
    	int whoami(std::vector<std::string>);
    	int listCards(std::vector<std::string>);
    	
    private:
    	typedef struct {
    		std::string name;
    		std::string help;
    	} commands;
    	static commands cmds[];
    };
    
    #endif	// SWCCG_CLIENT_H
    

    Thanks,
  • Can you show us the code of client.cpp, at least the first lines up to the #include statements.
  • Woops
    #include <Ice/Ice.h>
    
    //#ifdef _WIN32	
    //	#include <windows.h>
    //	#include <wtypes.h>
    //#endif
    
    #include <string>
    #include <vector>
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    
    #ifdef _WIN32
    #include "my_global.h"
    #endif
    
    #include "mysql.h"
    
    #include "client.h"
    #include "client_help.h"
    
    client::commands client::cmds[] = {
    	{ "connect", HELP_CONNECT },
    	{ "register", HELP_REGISTER },
    	{ "login", HELP_LOGIN },
    	{ "list", HELP_LIST },
    	{ "ping", HELP_PING },
    	{ "invite", HELP_INVITE }, 
    	{ "cards", HELP_CARDS }, 
    	{ "whoami", HELP_WHOAMI },
    	{ "quit", HELP_QUIT_ }
    };
    
    void client::join(SWCCG::ServerPrx server) {
    	this->server = server;
    	std::cout << "Joined server" << std::endl;
    }
    
    void client::disconnect() {
    	if (!this->server) return;
                    
    	try {
    		this->server->disconnect(this->player);
    		std::cout << "Disconnected from server" << std::endl;
    		this->server = NULL;
    	} catch (const Ice::Exception &e) {
            std::cout << "Server not responding." << std::endl;
        }
    }
    
    int client::run() {
    	screen->input();
    
    	return running;
    }
    etc..
    
  • Move client.h up to be the first include file and try again. Most likely some of the include files before client.h redefines "bool".
  • I remembered this post, from when it was just a small ICE sample app we had (never really solved it then..), the GUI and game are now merged and this should become our main development app.

    Probably the same problem, here's a buildlog and the corresponding headers:
    e:\Src\swccg\SWCCG\ICE\src\client.cpp(47): warning C4101: 'e' : unreferenced local variable
    client error LNK2001: unresolved external symbol "private: virtual class IceInternal::Handle<class IceDelegateD::Ice::Object> __thiscall IceProxy::SWCCG::Auth::__createDelegateD(void)" (?__createDelegateD@Auth@SWCCG@IceProxy@@EAE?AV?$Handle@VObject@Ice@IceDelegateD@@@IceInternal@@XZ)
    client error LNK2001: unresolved external symbol "private: virtual class IceInternal::Handle<class IceDelegateD::Ice::Object> __thiscall IceProxy::SWCCG::Server::__createDelegateD(void)" (?__createDelegateD@Server@SWCCG@IceProxy@@EAE?AV?$Handle@VObject@Ice@IceDelegateD@@@IceInternal@@XZ)
    client error LNK2001: unresolved external symbol "private: virtual class IceInternal::Handle<class IceDelegateM::Ice::Object> __thiscall IceProxy::SWCCG::Auth::__createDelegateM(void)" (?__createDelegateM@Auth@SWCCG@IceProxy@@EAE?AV?$Handle@VObject@Ice@IceDelegateM@@@IceInternal@@XZ)
    client error LNK2001: unresolved external symbol "private: virtual class IceInternal::Handle<class IceDelegateM::Ice::Object> __thiscall IceProxy::SWCCG::Server::__createDelegateM(void)" (?__createDelegateM@Server@SWCCG@IceProxy@@EAE?AV?$Handle@VObject@Ice@IceDelegateM@@@IceInternal@@XZ)
    client error LNK2001: unresolved external symbol "void __cdecl IceInternal::decRef(class IceProxy::SWCCG::Server *)" (?decRef@IceInternal@@YAXPAVServer@SWCCG@IceProxy@@@Z)
    client error LNK2019: unresolved external symbol "public: class IceInternal::ProxyHandle<class IceProxy::SWCCG::Auth> __thiscall IceProxy::SWCCG::Server::getAuth(void)" (?getAuth@Server@SWCCG@IceProxy@@QAE?AV?$ProxyHandle@VAuth@SWCCG@IceProxy@@@IceInternal@@XZ) referenced in function "public: int __thiscall client::create(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?create@client@@QAEHV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    client error LNK2019: unresolved external symbol "public: class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __thiscall IceProxy::SWCCG::Server::getMessages(struct SWCCG::Player const &)" (?getMessages@Server@SWCCG@IceProxy@@QAE?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@ABUPlayer@2@@Z) referenced in function "public: int __thiscall client::heartbeat(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?heartbeat@client@@QAEHV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    client error LNK2019: unresolved external symbol "public: class std::vector<struct SWCCG::Card,class std::allocator<struct SWCCG::Card> > __thiscall IceProxy::SWCCG::Server::getCards(struct SWCCG::Player const &)" (?getCards@Server@SWCCG@IceProxy@@QAE?AV?$vector@UCard@SWCCG@@V?$allocator@UCard@SWCCG@@@std@@@std@@ABUPlayer@2@@Z) referenced in function "public: int __thiscall client::listCards(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?listCards@client@@QAEHV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    client error LNK2019: unresolved external symbol "public: class std::vector<struct SWCCG::Player,class std::allocator<struct SWCCG::Player> > __thiscall IceProxy::SWCCG::Server::getList(void)" (?getList@Server@SWCCG@IceProxy@@QAE?AV?$vector@UPlayer@SWCCG@@V?$allocator@UPlayer@SWCCG@@@std@@@std@@XZ) referenced in function "public: int __thiscall client::list(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?list@client@@QAEHV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    client error LNK2019: unresolved external symbol "public: int __thiscall IceProxy::SWCCG::Auth::create(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?create@Auth@SWCCG@IceProxy@@QAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@000@Z) referenced in function "public: int __thiscall client::create(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?create@client@@QAEHV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    client error LNK2019: unresolved external symbol "public: int __thiscall IceProxy::SWCCG::Server::sendMessage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?sendMessage@Server@SWCCG@IceProxy@@QAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00@Z) referenced in function "public: int __thiscall client::invite(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?invite@client@@QAEHV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    client error LNK2019: unresolved external symbol "public: int __thiscall IceProxy::SWCCG::Server::setAuth(class IceInternal::ProxyHandle<class IceProxy::SWCCG::Auth> const &)" (?setAuth@Server@SWCCG@IceProxy@@QAEHABV?$ProxyHandle@VAuth@SWCCG@IceProxy@@@IceInternal@@@Z) referenced in function "public: int __thiscall client::connect(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?connect@client@@QAEHV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    client error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl IceProxy::SWCCG::Auth::ice_staticId(void)" (?ice_staticId@Auth@SWCCG@IceProxy@@SAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "class IceInternal::ProxyHandle<class IceProxy::SWCCG::Auth> __cdecl IceInternal::checkedCastImpl<class IceInternal::ProxyHandle<class IceProxy::SWCCG::Auth> >(class IceInternal::ProxyHandle<class IceProxy::Ice::Object> const &)" (??$checkedCastImpl@V?$ProxyHandle@VAuth@SWCCG@IceProxy@@@IceInternal@@@IceInternal@@YA?AV?$ProxyHandle@VAuth@SWCCG@IceProxy@@@0@ABV?$ProxyHandle@VObject@Ice@IceProxy@@@0@@Z)
    client error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl IceProxy::SWCCG::Server::ice_staticId(void)" (?ice_staticId@Server@SWCCG@IceProxy@@SAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "class IceInternal::ProxyHandle<class IceProxy::SWCCG::Server> __cdecl IceInternal::checkedCastImpl<class IceInternal::ProxyHandle<class IceProxy::SWCCG::Server> >(class IceInternal::ProxyHandle<class IceProxy::Ice::Object> const &)" (??$checkedCastImpl@V?$ProxyHandle@VServer@SWCCG@IceProxy@@@IceInternal@@@IceInternal@@YA?AV?$ProxyHandle@VServer@SWCCG@IceProxy@@@0@ABV?$ProxyHandle@VObject@Ice@IceProxy@@@0@@Z)
    *snip*
    

    Headers:
    #include <Ice/Ice.h>
    
    //#ifdef _WIN32	
    //	#include <windows.h>
    //	#include <wtypes.h>
    //#endif
    // // Commenting out the above does not make a difference.
    
    #include <string>
    #include <vector>
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    
    #include "client.h"
    
    #ifdef _WIN32
    #include "my_global.h"
    #endif
    #include "mysql.h"
    
    #include "client_help.h"
    

    Changing the libs to use defaults doesn't help.
  • PS.
    #ifdef _WIN32
    #include "my_global.h"
    #endif

    Seems to be the problem, since putting client.h above it produces the linker errors and below it produces the C2555.

    PPS. When I comment the above out, " #include "mysql.h" " does the same.
  • bernard
    bernard Jupiter, FL
    These link errors mean that you did not link with the .obj corresponding to the Ice generated code for SWCCG::Server, SWCCG::Auth etc, or a library that contains these .obj.

    For compile issues, the best is to post a simple test case that shows the problem.

    Cheers,
    Bernard