My emplyer is considering upgrading to RAD11 so I have to test if it suite our needs so I am in process of porting one of mine projects (Huge win32 CAD/CAM app) from BDS2006 into RAD 11 (trial version 28.0.44500.8973) and have workaround most of the problems (related to changes in VCL and WinAPI interface related to Unicode) but with this bug I hit a wall...
For some classes and structs (not all of them) sometimes (only on certain lines not all of them) the compiler is complaining about missing constructor which is always present in code like this (see the comments marked with // ***
):
//---------------------------------------------------------------------------
//--- Crypto ver: 1.24 ------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef _crypto_h
#define _crypto_h
//---------------------------------------------------------------------------
#define _mod_type DWORD
//---------------------------------------------------------------------------
struct _mod_type2
{
_mod_type h,l; // (high,low) or (integer,fractional)
_mod_type2() { h=0; l=0; }
_mod_type2(_mod_type2& a) { *this=a; } // *** this is the "missing" constructor
~_mod_type2() {};
_mod_type2* operator = (const _mod_type2 *a) { *this=a; return this; }
//_mod_type2* operator = (const _mod_type2 &a) { ...copy...; return this; }
_mod_type2(int a) { h=a; l=0; }
_mod_type2(_mod_type& a) { h=a; l=0; }
_mod_type2 operator = (int a) { h=a; l=0; return *this; }
_mod_type2 operator = (_mod_type& a) { h=a; l=0; return *this; }
int operator == (_mod_type2 a) { return (h==a.h)&&(l==a.l); }
int operator != (_mod_type2 a) { return (h!=a.h)||(l!=a.l); }
int operator >= (_mod_type2 a) { if (h!=a.h) return (h>a.h); return (l>=a.l); }
int operator > (_mod_type2 a) { if (h!=a.h) return (h>a.h); return (l> a.l); }
int operator <= (_mod_type2 a) { if (h!=a.h) return (h<a.h); return (l<=a.l); }
int operator < (_mod_type2 a) { if (h!=a.h) return (h<a.h); return (l< a.l); }
};
//---------------------------------------------------------------------------
bool error(_mod_type2 a,_mod_type2 b)
{
bool x;
x = (_mod_type2(a)>=_mod_type2(b)); // *** this line produce error
/*
[bcc32 Error] crypto.h(34): E2285 Could not find a match for '_mod_type2::_mod_type2(_mod_type2&)'
Full parser context
win_main.cpp(5): #include crypto.h
crypto.h(32): parsing: bool error(_mod_type2,_mod_type2)
*/
return x;
}
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
Its always a constructor like this:
class_name(class_name& a) { *this=a; }
Which I have in all of my structs and classes due to compiler bug in BDS2006
If I comment out the constructor (so C++ will use default one) the bug usually disappears but not for all classes/struct ...
The simple code above produce the error (just #include it to empty C++ win32 Form App project using Classic compiler).
So the Question is:
Q1 Is anything wrong with my code?
Q2 How to workaround this?
Using new compiler seems to compile this without problems however that is not an option as the whole project is not written for it and porting it would be a huge effort taking too long time (hitting much more walls like this and without the working RAD help in trial version its not a good idea in general at this point)...
PS All the QAs in here dealing with this error I found was due to really missing constructor which is not my case ...