3 ms·
Yep. Use some of the -W* flags (-Wall -Wpedantic -Wconversion, ...) and specify the standard -std=c90. Avoid undefined behaviors: - https://en.cppreference.c
by dankoncs 5y ago
Yep.
Use some of the -W* flags (-Wall -Wpedantic -Wconversion, ...) and specify the standard -std=c90.
Avoid undefined behaviors:
- https://en.cppreference.com/w/c/language/behavior https://en.cppreference.com/w/c/language/behavior
- https://wiki.sei.cmu.edu/confluence/display/c https://wiki.sei.cmu.edu/confluence/display/c
(Also use cppcheck, valgrind, gdb, astyle, make, ...)
Done.
Fun fact: JS and C are both standardized by ISO.
- throwawayapples 5y agoHave a look at Apache 1 (C) or KDE 1 (C++); it'd be interesting to see what you think of those codebases, and they can certainly predate 2001.
- Asooka 5y agoAnd always use "-fwrapv -fno-strict-aliasing -fno-delete-null-pointer-checks". Those are source of the hardest to reason about UB and the small performance benefit is not worth the risk. I would love to always be certain I haven't accidentally hit UB, but that's equal to the halting problem, so for peace of mind, I just ask the compiler for a slightly safer variant of the language. P.S. and old code definitely needs them, as at the time compilers didn't optimize so aggressively and lots of code does weird stuff with memory, shifts, etc.