This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Ram usage with ec++

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

Parents
  • 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.

Reply
  • 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.

Children
No data