VC7 compile errors that were not reported in VC6

T

TomTom

Hi,

I just opened a small VC6 project and tried to compile. This project does
not have error in VC6, but VC7 now reports errors below..

c:\myproj\inc\mit\mitutil\blobfile.h(79): error C2555:
'CBlobFile::GetPosition': overriding virtual function return type differs
and is not covariant from 'CFile::GetPosition'

c:\myproj\inc\mit\mitutil\blobfile.h(79): error C2555:
'CBlobFile::GetLength': overriding virtual function return type differs and
is not covariant from 'CFile::GetLength'

Why do I get these errors? How can I avoid them?
 
J

Julie

TomTom said:
Hi,

I just opened a small VC6 project and tried to compile. This project does
not have error in VC6, but VC7 now reports errors below..

c:\myproj\inc\mit\mitutil\blobfile.h(79): error C2555:
'CBlobFile::GetPosition': overriding virtual function return type differs
and is not covariant from 'CFile::GetPosition'

c:\myproj\inc\mit\mitutil\blobfile.h(79): error C2555:
'CBlobFile::GetLength': overriding virtual function return type differs and
is not covariant from 'CFile::GetLength'

Why do I get these errors? How can I avoid them?

VC7 is a more standards compliant C++ compiler, therefore you are seeing the
effects of better error reporting.

To solve this, you need to declare your override w/ the same return type as is
defined in the base class.
 
T

TomTom

Thanks for your help. Isn't there any setting to loosen up the error
checking? :)

If I need to fix this,do I need to specify the return type of
CBlobFile::GetPosition() as ULONGLONG? Sorry, I am not a pro, but need to
make this code work. Otherwise, I'll have to keep using VC6...

<From MSDN>
virtual ULONGLONG GetPosition( ) const;
 
J

Julie

TomTom said:
Thanks for your help. Isn't there any setting to loosen up the error
checking? :)

If I need to fix this,do I need to specify the return type of
CBlobFile::GetPosition() as ULONGLONG? Sorry, I am not a pro, but need to
make this code work. Otherwise, I'll have to keep using VC6...

<From MSDN>
virtual ULONGLONG GetPosition( ) const;

Yes, ULONGLONG should do it for you.
 
T

TomTom

Now I got an link error that looks like. Is this common to see this error
when upgrading to VC7? No idea what I can do to avoid this...

LNK2019: unresolved external symbol "__declspec(dllimport) public: class
CLString const & __thiscall CLString::blush:perator=(class
ATL::CStringT said:
const &)"
(__imp_??4CLString@@QAEABV0@ABV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCR
T@D@ATL@@@@@ATL@@@Z) referenced in function "int __cdecl ElimWhiteLeft(class
CLString &)" (?ElimWhiteLeft@@YAHAAVCLString@@@Z)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top