10 ms·
I learn C++ by example by using the VSCode debugger. I prefer it over gdb with tui. It won’t go all the way (e.g. educational/smallish projects only that are si
by mettamage 6y ago
I learn C++ by example by using the VSCode debugger. I prefer it over gdb with tui. It won’t go all the way (e.g. educational/smallish projects only that are single threaded) but by that time a programmer has seen some wonky things happening that they can hypothesize about. In my case:
- dangling pointers
- integer under/overflow
- macro expansion (not via debugger but VSCode helps with this)
- double values not being the same when you expect them to be the same
- Seeing if something is copied or moved [1]
[1] Not sure if this is actually true. But I think it can be true by simply stepping inside the function like emplace_back
- vbezhenar 6y agoIf you're using Linux, run your test programs under valgrind. It'll help you immensely to find memory issues.
- readams 6y agoI mostly use address sanitizer these days rather than valgrind. It's fast enough that you can just put it in your default compile flags for debugging.
- scatters 6y agoAnd it's available for Visual Studio, so you don't even need to be running Linux.
- junon 6y agoAddress sanitizers have bitten me before. Valgrind has not, aside from the times it wasn't supported on new macos. Just be careful.
- usefulcat 6y agoIt is faster, but IME valgrind is more thorough. I have an option to run unit tests with valgrind.