fl42v to Programmer Humor@programming.dev · 9 months agoYou can certainly change it. But should you?imagemessage-square58fedilinkarrow-up1538arrow-down18
arrow-up1530arrow-down1imageYou can certainly change it. But should you?fl42v to Programmer Humor@programming.dev · 9 months agomessage-square58fedilink
minus-squareOmega_HaxorslinkfedilinkEnglisharrow-up13arrow-down1·edit-29 months agoContext is very interesting: https://stackoverflow.com/questions/4592762/difference-between-const-const-volatile Const flags to the code that you cannot change the value, and volatile flags to the compiler that it’s not safe to change the value.
minus-squareblackstrat@lemmy.fwgx.uklinkfedilinkarrow-up4·9 months agoVolatile means that the value should be read each time its accessed. It can’t be cached in a register or the read be otherwise assumed and optimized away or the instructions around its access be reordered.
Context is very interesting: https://stackoverflow.com/questions/4592762/difference-between-const-const-volatile
Const flags to the code that you cannot change the value, and volatile flags to the compiler that it’s not safe to change the value.
Volatile means that the value should be read each time its accessed. It can’t be cached in a register or the read be otherwise assumed and optimized away or the instructions around its access be reordered.