如何为每个函数部分地切换编译器的优化级别?

时间:2018-07-13 06:36:44

标签: optimization compiler-optimization xc16

如何为每个函数将编译器(xc16)的优化级别切换到不同的级别?

例如:

void _ISR _T1Interrupt    //compile with O0
{
.....
}

int_16_t main (void)         //compile with O2
{
.....
}

1 个答案:

答案 0 :(得分:0)

我找到了解决方法:

__attribute__((optimize("-O0"))   //optimization for the next function is O0
void _ISR _T1Interrupt            //compile with O0
{
.....
}

__attribute__((optimize("-O2"))   //optimization for the next function is O2
int_16_t main (void)              //compile with O2
{
.....
}