Will the native CVI compiler (LCC compiler), in release mode, optimize the following such that it won't work?
Module 1:
int iFlag = 0; // top level variable, defining declaration
not declared as volatile or register
function1 () { while (1) {if (iFlag == 1) do something wonderful;}} // reads the top level variable but never writes to it. No other references to iFlag in module 1.
Module 2:
extern int iFlag // top level variable, referencing declaration
function2 () {iFlag = 1; return;}
Function 2 runs in a callback, sets the flag to signal function 1, and exits. function 1 reads the flag and does something wonderful.
Will the LCC compiler optimize function 1 and put the value of iFlag in a register rather than read it every time from memory? I don't fully understand the sequence point concept in C89. I think the compiler's not supposed to optimize across a sequence point: so if there's a sequence point in between the top level variable and the reference, it should never try to optimize the reference to it in function 1. I.e., the compiler is only allowed to optimize between sequence points.
Thanks.
Menchar