Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经制作了一些头文件,并将它们放在与主程序相同的文件夹中,但是编译命令gcc -ansi -Wall *.c找不到这些文件。我是否必须包含头文件的完整目录路径,还是我做错了什么?
gcc -ansi -Wall *.c
首先,如果您还没有这样做,则必须将头文件包含到相关的 C 文件中:
#include "path/to/file.h"
您还必须告诉编译器编译 .h 文件,因此如果您的 .h 文件与 .c 文件在同一个目录中,并且您想包含所有当前的 .h 文件,您的编译器命令看起来像这个:
gcc -ansi -Wall *.h *.c