3 ms·
Not bad reading for a beginner/intermediate C programmer. However, if you are targeting such, try to emphasize more on possible pitfalls, things to avoid and be
by kbart 13y ago
Not bad reading for a beginner/intermediate C programmer. However, if you are targeting such, try to emphasize more on possible pitfalls, things to avoid and best practices. What first comes to my mind:
1) Name variables in macro differently (e.g. _X instead of just X) and always use them in parentheses.
2) Always initialize pointers, especially in examples for beginners, as segmentation fault while stepping on uninitialized or dangling pointer is one of the most common errors I have seen.
3) Using -Wall compiler directive is also a good idea to see many possible problems you could miss otherwise.
4) Trick #15 is a really bad practice, it's way better to include header file that declares and defines array, something like Gimp or OpenSSL do when you choose to export output as a header file.
5) Just a suggestion: there is a very handy macro for debugging worth mentioning:
#ifdef DEBUG
#define DBG(fmt, ...) \
printf("%s: " fmt, __func__, ## __VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif