by forrestthewoods · 2y ago · 0 comments
A nice trick with MSVC is you can turn off optimizations for TU or any block of code with:
#pragma optimize( "", off )
Leaps and bounds easier than hacking the build the system. #pragma GCC optimize ("O0")
(see also target, push_options, and pop_options)This is also available as a per-function attribute, using both gnu and standard syntaxes:
__attribute__((optimize("O0")))
[[gnu::optimize("O0")]]Well, except the Debug build in MSVC doesn't do half of the things from this list. Also, the list tells you how to use the compilation driver directly, so when comparing stuff, you would need to use the "cl.exe" compiler. For a "default" debugging experience it's enough to use CMake's Debug build type. It even has a built-in "release with debug info" build type.
I got pretty much the same on Linux when using CLion IDE from JetBrains.