Re:Ask HN: Good practices for my first C project
by bluecalm on Wednesday October 18, 2023 @05:39PM
(#37935143)
Initializing variables means the compiler will not be able to warn you when you use ununitialized value. I prefer to get the warning than use zero initialized one by accident.
Build.c file - good idea if
performance is priority but you remove an option to get incremental builds (with make or the like).
I would add: read about warning options and enable as many as sensible ("-Wall -Wextra -pedantic from memory but there are a few others). Treat warnings seriously, don't allow them for longer than debugging/experimenting stage.
C99 has some useful features (like designated initializers or compound literals). Check if your compiler supports it.
Build.c file - good idea if performance is priority but you remove an option to get incremental builds (with make or the like).
I would add: read about warning options and enable as many as sensible ("-Wall -Wextra -pedantic from memory but there are a few others). Treat warnings seriously, don't allow them for longer than debugging/experimenting stage.
C99 has some useful features (like designated initializers or compound literals). Check if your compiler supports it.