Headers include in multiple C files
问题 I have two files foo.c and bar.c that I compile separately with gcc -c and then link. Both files need the stdio.h and stdlib.h headers. Do I have to include them in both? Doesn't feel a little redundant? Should I maybe use #ifdef? What's the best practice? 回答1: Each C file is a different translation unit . In other words, it is an entire separate program , syntactically complete and correct. Thus, each C file must compile independently of any other C file, and must contain every declaration