Closed tdolphin-org closed 1 year ago
You have to redesign your code. The amiga hunks can't support this.
it yields now:
@@@@@@ static ClassSinleton& ClassSinleton::instance()0xc93ac
@@@@@@ static ClassSinleton& ClassSinleton::instance()0xc93ac
Amiga
@@@@@@ static ClassSinleton& ClassSinleton::instance()0xc93ac
Amiga
@@@@@@ static ClassSinleton& ClassSinleton::instance()0xc93ac
@@@@@@ static ClassSinleton& ClassSinleton::instance()0xc93ac
MorphOS
it yields now:
You are great!! Thanks!
This problem is related to one of known singletons patterns, when constructor is private, and there is only static method
instance
which has static variable with type of this class, the object is created only once and returned from method. Here is example code below (few files):Main.cpp
ClassSinleton.hpp
ClassSinleton.cpp
SomeClass.hpp
SomeClass.cpp
The expected result (after compiled and run it on linux) is:
But compiled using m68k-amigaos-g++ and run under AmigaOS result is:
As we can see the object is created again if singleton
instance()
is called from other source file/class, what is wrong. Also I have check and such problem not exists under MorphOS with the latest g++ from MOS SDK.