include - C header file dependencies -
i typically include dependencies in header files when adding header source file, don't need dig around other required headers make compile.
however, after reviewing other coding standards, appears banned, requirement header file not contain #include statements.
i can't find discussion on - reason banning such practice, or purely down preference?
--
e.g. typedef.h contains typedef u8. my_header.h declares void display_message(u8 arg);
should reference typedef.h go my_source_file.c or my_header.h ??
i see no reason not allowing headers include prerequisites.
consider deleting #include
source file. example, suppose code has been modified no longer use foo.h
, #include
being deleted. source files has dozen #include
statements. other ones should delete because no longer needed? hopefully, foo.h
documents prerequisites, can identify candidates deletion. however, if delete #include
statements, might deleting prerequisite needed different header file. must check prerequisites of every header file.
in contrast, if headers include prerequisites, can delete #include <foo.h>
, done it.
Comments
Post a Comment