I've worked with a number of C projects during my programming career and the header file structures usually fall into one of these two patterns:
- One header file containing all function prototypes
- One
.h
file for each.c
file, containing prototypes for the functions defined in that module only.
The advantages of option 2 are obvious to me - it mokes it cheaper to share the module between multiple projects and makes dependencies between modules easier to see.
But what are the advantages of option 1? It must have some advantages otherwise it would not be so popular.
Related to question 181921.
This question would apply to C++ as well as C, but I have never seen #1 in a C++ project.
Placement of #define
s, struct
s etc. also varies but for this question I would like to focus on function prototypes.