This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

在使用优化选项/O1/O2/O3时,有些函数会被优化去掉,有没有什么方法可以让指定函数不会被优化去掉?

如题,谢谢

  • 1) For GCC, please try below method:

    #pragma GCC push_options
    #pragma GCC optimize ("O0")

    your code

    #pragma GCC pop_options
    to disable optimizations since GCC 4.4.



    2) For Microsoft compiler, it also supports below grammar:

    #pragma optimize( "[optimization-list]", {on | off} )

    3)For ARM AC5/AC6, I do a quick go through but I don't find it.  Maybe I miss it. 
    Anyway, you can try it as what GCC does.

    4) The last method is to try a unnecessary "volatile" to your function.