I have posted this question below in a related thread but have no answer, and I dont seem to be able to put a support ticket in anymore...
The compiler option of O0, O1, O2, Os in Debug mode
I have some issues with my project using a struct that wont work correctly in release. Below I have fixed it by turning optmisation down to 0 for the struct but I am not 100% sure its pushing an popping the optmizations as the "correct way" is broken (still)... Anyone confirm if this is right, or, how I should do it knowing #pragma GCC pop_options is broken? I cannot get __attribute__((optimize("O0"))) to work, if someone can tell me how to add this attribute to a struct below that might help.
unsigned long value2;
extern volatile ramtable_s RamTable;
#pragma GCC optimize("O0")
volatile ramtable_s RamTable =
.value1 = 0;
.value2 = 10;
.string1 = "TEST";
PS the #pragma GCC optimize("O0") is 100% working in this case, but, im worried its staying at level 0 for the rest of the code and I am not sure how to prove / disprove this.
the other way to resolve this is to have some sort of SECTION defined and KEEP it in the linker.