代码之家  ›  专栏  ›  技术社区  ›  Mike

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

  •  0
  • Mike  · 技术社区  · 8 年前

    如何为每个函数在不同的级别上切换编译器(XC16)的优化级别?

    例如:

    void _ISR _T1Interrupt    //compile with O0
    {
    .....
    }
    
    int_16_t main (void)         //compile with O2
    {
    .....
    }
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Mike    8 年前

    我找到了解决办法:

    __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
    {
    .....
    }