Assuming spatulas are absent, I've never had a problem with the build system on Linux. Nonetheless, for GCC the equivalent is:
#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")]]
Re:How to build highly-debuggable C++ binaries
by bialpio on Monday July 29, 2024 @04:59PM
(#41103729)
For completeness, in Clang `[[clang::optnone]]` as a per-function attribute also works fine. I'm using it for debugging quite frequently lately.
Re:How to build highly-debuggable C++ binaries
by aseipp on Monday July 29, 2024 @02:20PM
(#41102511)
I mean, to be fair, if you're fiddling with/invoking cl.exe manually then you'd need to know a lot of the general equivalents and nits listed here. MSVC's debug build will do a lot for you out of the box though which is great. That said you often have to support/know 400 random build tools when using C++ to enable things like this, so it's often useful knowledge anyway.
Re:How to build highly-debuggable C++ binaries
by FpUser on Monday July 29, 2024 @12:50PM
(#41101795)
>"On Windows you pretty just need to make a debug build and… that’s it!"
I got pretty much the same on Linux when using CLion IDE from JetBrains.
Re:How to build highly-debuggable C++ binaries
by self_awareness on Tuesday July 30, 2024 @03:28AM
(#41106848)
> I’m surprised it requires so much effort. On Windows you pretty just need to make a debug build and... that’s it!
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.
Re:How to build highly-debuggable C++ binaries
by OvbiousError on Tuesday July 30, 2024 @05:23AM
(#41107427)
I guess that means not using cmake but using sln and vcxproj and friends, my experience with those was that it's pretty terrible for anything bigger than simple dummy projects.
A nice trick with MSVC is you can turn off optimizations for TU or any block of code with:
Leaps and bounds easier than hacking the build the system.