Hello !
I have to port one DLL written in BC++ 4.5 to VC 6.
Some code don't port correctly and I have some difficulties with the
following lines which are not correctly interpreted in VC6
I have included hereafter the .h and .cpp involved and the errors produced
!
what's wrong ? thanks !
--------
/*
Header : intface.h
*/
// Exception handling constants
enum IFACE_ERROR {
IFACE_INIT_ERRO R,
IFACE_RESTORE_E RROR,
IFACE_TIME_OUT,
IFACE_DRIVER_TE ST_ERROR,
IFACE_WRITE_ERR OR,
IFACE_UNDEFINED _ERROR
};
// Exception handling class
class IfaceError : public ClassError
{
public:
IfaceError(IFAC E_ERROR, char*, char*, char*, unsigned int);
IFACE_ERROR exceptionCode;
};
/* Definition des types d'erreurs */
enum { RISC_OK = 0, BAD_ECHO, TIME_OUT, DEFAULT_DRIVER };
// Design class
class Interface
{
public:
Interface(void) { slaveBit = 0; };
virtual ~Interface(){};
int operator==(cons t Interface&);
virtual void InitCom (int)=0;
virtual void RestoreCom (void)=0;
RWCString& getName(void);
static int RiscTimeOut;
int isSlave (void) { return slaveBit; };
void setIsSlave (void) { slaveBit = 1; }
protected:
RWCString name;
int slaveBit;
};
// Design hash function for Interface object
unsigned hashInterface(c onst Interface&);
/*
Header : intface.cpp
*/
#include "intface.h"
// Static member initialisation
int Interface::Risc TimeOut;
RWCString& Interface::getN ame(void)
{
return name;
}
// Design class : Interface
Interface::oper ator==(const Interface& inter)
{
return name==inter.get Name();
}
\INTFACE.CPP(39 ) : error C2662: 'getName' : cannot convert 'this' pointer
from 'const class Interface' to 'class Interface &' Conversion loses
qualifiers
// Design hash function for Interface object
unsigned hashInterface(c onst Interface& iface)
{
return iface.getName() .hash();
}
\INTFACE.CPP(51 ) : error C2662: 'getName' : cannot convert 'this' pointer
from 'const class Interface' to 'class Interface &' Conversion loses
qualifiers
\INTFACE.CPP(51 ) : error C2228: left of '.hash' must have class/struct/union
type
// Design class : IfaceCanError
IfaceError::Ifa ceError(IFACE_E RROR code, char *module="", char *object="",
char *method="", unsigned int line=0) :
exceptionCode(c ode),
ClassError(modu le,object,metho d,line)
{
}
--
Francis
I have to port one DLL written in BC++ 4.5 to VC 6.
Some code don't port correctly and I have some difficulties with the
following lines which are not correctly interpreted in VC6
I have included hereafter the .h and .cpp involved and the errors produced
!
what's wrong ? thanks !
--------
/*
Header : intface.h
*/
// Exception handling constants
enum IFACE_ERROR {
IFACE_INIT_ERRO R,
IFACE_RESTORE_E RROR,
IFACE_TIME_OUT,
IFACE_DRIVER_TE ST_ERROR,
IFACE_WRITE_ERR OR,
IFACE_UNDEFINED _ERROR
};
// Exception handling class
class IfaceError : public ClassError
{
public:
IfaceError(IFAC E_ERROR, char*, char*, char*, unsigned int);
IFACE_ERROR exceptionCode;
};
/* Definition des types d'erreurs */
enum { RISC_OK = 0, BAD_ECHO, TIME_OUT, DEFAULT_DRIVER };
// Design class
class Interface
{
public:
Interface(void) { slaveBit = 0; };
virtual ~Interface(){};
int operator==(cons t Interface&);
virtual void InitCom (int)=0;
virtual void RestoreCom (void)=0;
RWCString& getName(void);
static int RiscTimeOut;
int isSlave (void) { return slaveBit; };
void setIsSlave (void) { slaveBit = 1; }
protected:
RWCString name;
int slaveBit;
};
// Design hash function for Interface object
unsigned hashInterface(c onst Interface&);
/*
Header : intface.cpp
*/
#include "intface.h"
// Static member initialisation
int Interface::Risc TimeOut;
RWCString& Interface::getN ame(void)
{
return name;
}
// Design class : Interface
Interface::oper ator==(const Interface& inter)
{
return name==inter.get Name();
}
\INTFACE.CPP(39 ) : error C2662: 'getName' : cannot convert 'this' pointer
from 'const class Interface' to 'class Interface &' Conversion loses
qualifiers
// Design hash function for Interface object
unsigned hashInterface(c onst Interface& iface)
{
return iface.getName() .hash();
}
\INTFACE.CPP(51 ) : error C2662: 'getName' : cannot convert 'this' pointer
from 'const class Interface' to 'class Interface &' Conversion loses
qualifiers
\INTFACE.CPP(51 ) : error C2228: left of '.hash' must have class/struct/union
type
// Design class : IfaceCanError
IfaceError::Ifa ceError(IFACE_E RROR code, char *module="", char *object="",
char *method="", unsigned int line=0) :
exceptionCode(c ode),
ClassError(modu le,object,metho d,line)
{
}
--
Francis
Comment