F
Francis Goblet
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_ERROR,
IFACE_RESTORE_ERROR,
IFACE_TIME_OUT,
IFACE_DRIVER_TEST_ERROR,
IFACE_WRITE_ERROR,
IFACE_UNDEFINED_ERROR
};
// Exception handling class
class IfaceError : public ClassError
{
public:
IfaceError(IFACE_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==(const 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(const Interface&);
/*
Header : intface.cpp
*/
#include "intface.h"
// Static member initialisation
int Interface::RiscTimeOut;
RWCString& Interface::getName(void)
{
return name;
}
// Design class : Interface
Interface:
perator==(const Interface& inter)
{
return name==inter.getName();
}
\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(const 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::IfaceError(IFACE_ERROR code, char *module="", char *object="",
char *method="", unsigned int line=0) :
exceptionCode(code),
ClassError(module,object,method,line)
{
}
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_ERROR,
IFACE_RESTORE_ERROR,
IFACE_TIME_OUT,
IFACE_DRIVER_TEST_ERROR,
IFACE_WRITE_ERROR,
IFACE_UNDEFINED_ERROR
};
// Exception handling class
class IfaceError : public ClassError
{
public:
IfaceError(IFACE_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==(const 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(const Interface&);
/*
Header : intface.cpp
*/
#include "intface.h"
// Static member initialisation
int Interface::RiscTimeOut;
RWCString& Interface::getName(void)
{
return name;
}
// Design class : Interface
Interface:
{
return name==inter.getName();
}
\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(const 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::IfaceError(IFACE_ERROR code, char *module="", char *object="",
char *method="", unsigned int line=0) :
exceptionCode(code),
ClassError(module,object,method,line)
{
}