Headers include in multiple C files

前端 未结 5 1072
囚心锁ツ
囚心锁ツ 2021-01-03 05:03

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 in

5条回答
  •  情话喂你
    2021-01-03 05:28

    You will have to include the header in any file which is compiled by itself even if you will be linking it later.
    There is already an #ifdef in the header so that it will only be actually used once.

提交回复
热议问题