10 ms·
Great post. I’m surprised it requires so much effort. On Windows you pretty just need to make a debug build and… that’s it! A nice trick with MSVC is you can t
by forrestthewoods 2y ago
Great post. I’m surprised it requires so much effort. On Windows you pretty just need to make a debug build and… that’s it!
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.
- FpUser 2y ago>"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.
- aseipp 2y agoI 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.
- o11c 2y agoAssuming 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")]]
- bialpio 2y agoFor completeness, in Clang `[[clang::optnone]]` as a per-function attribute also works fine. I'm using it for debugging quite frequently lately.
- self_awareness 2y ago> 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.
- OvbiousError 2y agoI 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.
- dhashe 2y ago(author) Nice! I did not know about these pragmas. I have added them to the post as another option and credited y’all in a footnote.