consts and #defines are useful but there is a better way, which will ensure the compiler considers it a compile time constant.Use an enum, they are effectively more constant than a variable marked const. Sometimes the compiler cannot always guarantee a variable is a compile time constant, whereas an enum is by nature.

Sometimes the compiler cannot always guarantee a variable is a compile time constant, whereas an enum is by nature.

Can you explain that? I know that const-ness can be cast away or lost in some situations, but I would have thought that a const instance of an Enum type can lose its const-ness in exactly the same way that a const instance of an int type can.

I only provide help via the forum - please do not contact me for private consultancy.