Open charly61ch opened 6 years ago
Hi, Charly! Please provide your test code in one module (lets call it main.ino). I'll try to get it work. If it's not a big deal I'll add this to next release of compiler. Architecture of the chip is very ancient(Too old to rock&roll :) ). It has only about 100 bytes of stack for all, but I'll try to take it to its limits.
Hello @p0lyg0n1 Thanks for your answer. Here joint the "whole" :-) code I would like to use as "basis". (little "academic" for now, but will grow :-) )
iObjIface
defines the interface
cObjSwitch
has to callback client->SetValue
. The client is registrable by calling its setObjIface
function
cObjSibir
is the "client" object, which inherits iObjIface,
SIB010.INO :
cObjSibir Sibir; // inherits iObjIface
cObjSwitch Switch;
void setup()
{
Switch.setObjIface(&Sibir); // Not compilable
also :
iObjIface * p = &Sibir; // Not compilable
iObjIface * p = (iObjIface*)&Sibir; // Not understandable by compiler (but not dramatic if implicit cast will work)
}
So given, the code compiles, except SIB010.ino, line 33
Still thanks,... and more if you have a solution. :-) And very big congratulation to guys who developed a so simple, easy and genial customizable zwave device.
Ptr_To_Inherited_Base_Class Cannot_UpCast.zip
Regards, Charly
Dears,
I would like to use my favorite OOP construction like "Interface Injection". I have a class cIF, which declares a pure virtual function, as an interface, like a callback. I have a class cOBJECT, which inherits and implements the function. I have a class cHANDLE, which don't know cOBJECT, but knows cIF. This class has a function setInterface(cIF * pIf), which stores a "client" interface pointer object. In my "main.ino" module, I instantiate statically a cOBJECT obj and a cHANDLE hdl. In the Setup function, I would like to call hdl.setInterface(&obj).
BUT I cannot compile this last statement. I cannot cast in any other way, any pointers. The error is : "indirections to different types assignment". from type 'struct cxxclasscOBJECT_s generic xdata' to type 'struct cxxclasscIF_s generic auto' I understand the error, ant the difficulty for the compiler to handle the memory spaces, and my question is : Is my wish possible ? Can I expect a compiler upgrade to support that ?
Thanks in advance for an answer, Regards, Charly C.