5 Replies Latest reply on Aug 28, 2015 6:03 PM by user_343349849

    Variables being optimized out


      Maybe the weather is a bit colder today and this explains it?


      I am experiencing the compiler optimizing out most of my variables. I have made almost all of them volatile and still cannot prevent it happening. In the attached the array "Sensor[sensorLocation]" does not provide watch elements for the array and when I hover over "sensorLocation" the dialog announces it is "optimized out".


      I have a variable called "NumSensors" in the header file of a header file. Several other modules access the variable (which is also made volatile).


      The first module initializes the sensors and sets NumSensors ok. Then the first module calls another module (which does not use NumSensors at all), then when returned back to first module, NumSensors keeps setting back to 0. I had to move the declaration for NumSensors into the first module to prevent it loosing its value.


      What could be causing this behavior? I never experienced this in Creatore 3.1, then started to get some of these issues with Creator 3.2 and now it appears much worse in 3.2 SP2. Is there some compiler directive or something 3.2 , SP2 is switching on that affects the variable values being held in memory?