Unlike register or inline, which are completely deprecated, const actually can help the compiler to optimize, especially in embedded, where read only vars can be stored in flash.
Isn’t it the case that compilers aren’t actually able to determine whether a const variable is actually const the majority of the time? You know, cause you’re just able to cast it away in C.
Sure, maybe for a select few cases it actually provides a benefit, but I believe it provides none for local non-static variables
View all comments
Show parent comment
25
u/TheChief275 Mar 02 '26
Well, const in C is a suggestion anyways so why not cut out the middleman