How to change code optimization for a particular function/interrupt?
Hi everyone,
I am working with some interrupt stuff and the interrupt needs to be fast. I need at least "-O2" optimization in gcc. However, setting the whole project to O2 is not a good solution as debugging becomes quite hard.
I found two possibilities to tell gcc a custom optimization setting for a particular function:
Add the optimize attribute:
void __attribute__ ((optimize("-O2"))) EXTI4_15_IRQHandler(void)
{
// ...
}Or use the pragma command:
#pragma GCC push_options
#pragma GCC optimize ("-O2")
void EXTI4_15_IRQHandler(void)
{
// ...
}
#pragma GCC pop_optionsSadly both methods have no effect on the optimization.
I also tried this with a normal function, in case it is something special about the interrupt, but it also did not work.
Any suggestions?
