I would like to add one very good practice (both in C and C ++) that often leaves:
foo.c
#include "foo.h"
Any other necessary headers should follow, followed by code. The fact is that you almost always need this header for this compilation unit in any case, including the first directive, ensuring that the header remains self-sufficient (if it is not, there will be errors). This is especially true for public headlines.
If at any time you need to put something before including the header (with the exception of the comments, of course), then most likely you are doing something wrong. If you really donβt know what you are doing ... which leads to another decisive rule => comment on your hacks!
Alex Jun 30 '13 at 7:04 on 2013-06-30 07:04
source share