7 years, 10 months ago.

Can I control the level of optimization of the compiler?

Basically what the title says.. Is this possible? In order to avoid over optimization??

3 Answers

7 years, 10 months ago.

This may helps.
http://infocenter.arm.com/help/topic/com.arm.doc.dui0472l/chr1359124984478.html

#pragma O0 // makes minimum optimization level.


Please note that mbed online compiler option is -O3 -Otime by default.
https://github.com/mbedmicro/mbed/blob/master/workspace_tools/toolchains/arm.py

Accepted Answer

Thanks I ll try it it work (it is a letter "O" followed by a zero :)

unfortunately it did not solve my problem. Thanks again

posted by Cristian Fuentes 19 May 2016
7 years, 10 months ago.

I don't know if this is possible in the online compiler, but if you export to GCC ARM then you can control optimisations by editing the CC_FLAGS variable in the Makefile.

7 years, 10 months ago.

Hello,
Perhaps this isn't exactly what you are looking for but in some situations it could help:
By declaring a variable as volatile one can prevent the compiler from optimizing the code associated with that variable.

I also had an variable which has been changed by an interrupt handler and a main while loop was not existing, the volatile solved it.

posted by Helmut Tschemernjak 19 May 2016

Thank you, Yes, so far I have been solving problems like this with volatile, just as Helmut says.

posted by Cristian Fuentes 20 May 2016