What is the equivalent of GCC's #pragma GCC optimize("O0") or VS's #pragma optimize("", off) in Apple LLVM 5.0 compiler?

I need it to disable optimizations for just a section of code.

有帮助吗?

解决方案

From a brief search it doesn't look like clang/llvm supports such a pragma at this time. If you don't want to turn off optimizations for an entire file I suggest factoring what you don't want optimized into a separate file and setting -O0 on it separately.

其他提示

Actually there is now a way to do that by specifying an __attribute__ ((optnone)) to the function that wraps the code you don't want to be optimized.

For instance I'm using it to have a clear benchmark of an inline function

static void BM_notoptimizedfunction(benchmark::State& state) __attribute__ ((optnone)) {
    // your code here won't be optimized by clang
}

And that's it !

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top