How much effort do you invest to develop a const-correct design?
Did a later addition of the type modifier "const" for a function
interface uncover any real errors and bugs in your source code at
compile time?
I spend a lot of effort on const-correct design, although of course it
depends on what you mean by const-correct. Every pointer passed to a
function is const-qualified if the pointed-to object is not to be
modified. On the other hand, I do not bother with const qualification
at all for non-pointer value parameters.
Data that is truly constant is defined const. In small embedded
systems, where I do a lot of my work, non-constant initialized objects
take up space in the non-volatile program storage (ROM, EEPROM,
flash), and additional space in RAM, plus extra time at program start
up as they must be copied from non-volatile storage to RAM.
On higher performance systems, where code is copied from relatively
slow flash to high speed DRAM for execution, and on desk top systems
where code is copied from disk image to RAM, many platforms allow for
constant data to be in a memory area that will generate an exception
if the program tries to write to it. Turns up code defects quickly.