Suppose I have variables for positions like
const float latitude = 51.+11./60.+33.0461/3600.;
const float longitude = 12.+50./60.+31.9369/3600.;
and use them frequently in the program. Does the compiler precompute that? (This example should not produce much overhead, but you get the point.)
Bonus point for pointing out location. ;)
TIA
I don't believe it is required for the compiler to compute the result of arithmetic constant expressions in general.
The compiler is, however, required to compute the result of an integral constant expression (basically, a constant expression composed only of integers and other values converted to integers) in cases where it needs the result--that is, when an integral constant expression is used as an array size, as a case
expression, as an enumerator value, etc.
I'd be surprised, however, if any modern compiler didn't compute the result of a constant expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With