News for hackers. Stuff that matters.
Re:Modern C by codr7 on Friday September 04, 2020 @08:28AM (#24374322)
The list would be infinite; and it's a feature, not a bug. You pick up strategies for avoiding problems along the way, to a higher degree than in less flexible languages.

Valgrind is your friend, I couldn't imagine writing C without it anymore.

Many compilers also ship with verifiers for undefined behavior which has saved me a couple of times.

Re:Modern C by flohofwoe on Friday September 04, 2020 @08:35AM (#24374360)
Also: enable all warnings the compiler offers and compile the code with different compilers (clang, gcc, MSVC - they all have different warnings), add copious amounts of assert checks, compile and test with the clang sanitizers enabled (address sanitizer, undefined behaviour sanitizer, thread sanitizer), and run the code through static analyzers (e.g. clang static analyzer and the one in Visual Studio), minimize dynamic allocation and pointer use.

With all those combined it's quite hard to hit segmentation faults and memory corruption and the source code will generally become "cleaner" and more robust.

Re:Modern C by manishsharan on Friday September 04, 2020 @09:25AM (#24374708)
This. I wish all C books had more chapters on this.
Re:Modern C by saagarjha on Friday September 04, 2020 @12:23PM (#24376359)
Not all the warnings, as many are not useful. But take -Wall -Wextra and see how that suits you and tweak it if necessary.
Re:Modern C by nwmcsween on Saturday September 05, 2020 @02:35AM (#24381770)
I really wish compilers had a -Wstandard and that warned on standard breaking things vs -Wall or -Wextra which has compiler specific junk like -Wparentheses
Re:Modern C by saagarjha on Saturday September 05, 2020 @02:48AM (#24381808)
Perhaps -Wpedantic is what you want?
Re:Modern C by nwmcsween on Sunday September 06, 2020 @03:43AM (#24389746)
No, I basically want a W switch to warn only on potential buggy code (implicit-int, etc)