We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
as I understand from this link: www.caravan.net/.../guide.html in point D1 it is not possible to put an object in ROM if that object is from a class that has been derived from another class, even though everything is const.
Isn't this a huge limitation in the embedded world with it's limited RAM?
Jef
As Andy notes, I'm not sure if it is true.
The important thing is how clever the compiler and linker is at anaylyzing all potential writes to the object.
A user-defined constructor would normally make changes to the object. An inherrited class may call a base class where the constructor does make changes. An object with virtual methods may be overriden by an alternative implementation that does change fields in the object.
The problem here is that the constructors and destructor for an object are not const, and only if the compiler/linker can prove that no non-const methods can be called on the object will it be safe to place the object in ROM.
I don't think there is a standard that forbids placing a const object in ROM if the tools can prove that it is safe. The general case is that the compiler can't.