Headers include in multiple C files

前端 未结 5 1079
囚心锁ツ
囚心锁ツ 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:07

    You must include your header with both files. The header is just a list of function declarations and constant declarations. The compiler needs these to make sure your syntax and function calls are correct.

提交回复
热议问题