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.
I defined a global static const object of the user-defined class type, assuming that the compiler may understand that object can be plce on ROM.I found that the arm compiler is really good at empty base class optimization, however, tt is not able to find out the "static const" c++ object is ROM-able...
The RAM is really a kind of scarce resource for MCUs. Is there any way to tell the compiler that a c++ const object is ROM-albe ?
By the way, the discussion about ROM-able can be found from the book Effective C++ in an Embedded Environment.
Sorry, that's too much for me (I would say "Poor compiler" :)).
I think if you want to get smart code generated, you should take care that such variable initialisation is done in a straight-forward clear way. I do not understand the reason why you use constructor functions instead of the much easier direct static assignment.
I would use the direct static assignment too, if I could find any alternative solution in this case. Maybe I have to accept the fact that the compiler is not smart enough :) I was just wondering whether there was any compiler specific instruction to tell the compiler that an object is ROM-able.