且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:没有这样的文件或目录-C

更新时间:2022-06-23 05:29:10

list.h 在与包含它的c文件相同的目录。

list.h is in the same directory as the c files which include it. When you do

#include "list/list.h"

编译器尝试在包含路径+ / list 中查找文件。例如,它将查找不会退出的 list / list / list.h

the compiler tries to find the file in include path + /list. For instance, it will look for list/list/list.h which doesn't exit.

那又如何呢?将工作将更改为 #include list.h

So what would work would be changing to #include "list.h"

OR

使用 -I将当前目录添加到命令行。这样, list / list.h

gcc -Wall -g -I. -DARRAY ./list/*.c testList.c -o testList

来自 gcc搜索路径文档


-I。 -I-完全不同于没有-I选项,并且对于<>包括包括没有特殊选项的get不会导致相同的行为。 -I。在编译器的当前工作目录中搜索头文件。可能与包含当前文件的目录相同,也可能不同。

在任何包含路径的地方都没有提及包含从中启动gcc的当前目录。

It's not mentioned anywhere that include path contains the current directory, from which gcc was started.