Say I have a C program which is broken to a set of *.c and *.h files. If code from one file uses functions from another file, where should I include the header file? Inside the *.c file that used the function, or inside the header of that file?
E.g. file foo.c
includes foo.h
, which contains all declarations for foo.c
; same for bar.c
and bar.h
. Function foo1()
inside foo.c
calls bar1()
, which is declared in bar.h
and defined in bar.c
. Now the question is, should I include bar.h
inside foo.h
, or inside foo.c
?
What would be a good set of rules-of-thumb for such issues?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…