I am looking for a suitable and accepted way to prevent reordering of commands in the WindRiver C compiler (AKA Diab C (?)). The problem is that I have to write hardware registers several times within the same function, and I donβt want the optimizer to reorder the sequence or worse, to collect several records into one. Please do not recommend βmutableβ because I do not want to rely on this invisible and unreliable precondition (mainly because the definition may not be under my control). I am currently using an empty inline assembler statement:
asm volatile (" ");
as a surrogate, because the compiler reports that it will prevent reordering, OTOH, perhaps there is a more general way that every worthy WindRiver C user should be aware of.
early
source share