문제

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