[英]GCC cannot recognize the directory path inside a file
The problem I encountered in using GCC is that I cannot use the command make
to build my program because some files contain the paths of their actual location. 使用GCC时遇到的问题是我无法使用命令
make
来构建程序,因为某些文件包含其实际位置的路径。
Say I have a file named "machine.h", its content is target-pisa/pisa.h
. 假设我有一个名为“ machine.h”的文件,其内容为
target-pisa/pisa.h
At the same time, in the same working directory, I have a folder named "target-pisa", in which there is a file named "pisa.h"; 同时,在同一工作目录中,我有一个名为“ target-pisa”的文件夹,其中有一个名为“ pisa.h”的文件; the actual code of the header file "machine.h" is actually inside the file "pisa.h", which is inside the folder named "target-pisa" located in the same working directory as "machine.h".
头文件“ machine.h”的实际代码实际上位于文件“ pisa.h”内部,该文件位于与“ machine.h”相同的工作目录中的名为“ target-pisa”的文件夹中。
Assume for some reason I cannot simply copy and paste the code from "pisa.h" to "machine.h"; 假设由于某种原因,我不能简单地将代码从“ pisa.h”复制并粘贴到“ machine.h”; that is, I have to stick with what is provided by the prof.
也就是说,我必须坚持教授提供的内容。 The
make
command does not work in this case in my laptop because it cannot interpret target-pisa/pisa.h
as a directory path and open the actual header file "pisa.h" according to the path target-pisa/pisa.h
provided in the file "machine.h". 在这种情况下,
make
命令在我的笔记本电脑中不起作用,因为它无法将target-pisa/pisa.h
解释为目录路径,并且无法根据提供的路径target-pisa/pisa.h
打开实际的头文件“ pisa.h”在文件“ machine.h”中。 Instead, git bash interprets target-pisa/pisa.h
as C code (if I am not mistaken); 相反,git bash将
target-pisa/pisa.h
解释为C代码(如果我没记错的话); see the figure below. 参见下图。
Some additional info that may be helpful: 一些其他信息可能会有所帮助:
In machine.h
, there is only one line of code as shown below: target-pisa/pisa.h
在
machine.h
,只有一行代码,如下所示: target-pisa/pisa.h
I have checked that almost all .c
files in the working directory have #include "machine.h"
. 我已经检查了工作目录中几乎所有
.c
文件都具有#include "machine.h"
。
How can I solve this problem? 我怎么解决这个问题? Please help, I have been stuck in this for a long time.
请帮助,我已经被困了很长时间了。 By the way, my friend also used git bash to do this lab and this problem doesn't happen to him.
顺便说一句,我的朋友还使用git bash进行了此实验,但他没有发生此问题。
I tried to reinstall git bash in order to see if the problem can be solved, but it didn't. 我尝试重新安装git bash以查看问题是否可以解决,但是没有解决。
All in all, I want to build the program successfully by using make
command in git bash. 总而言之,我想通过在git bash中使用
make
命令成功构建程序。
machine.h
needs to have an #include
directive to tell the compiler to pull in the nested header. machine.h
需要具有#include
指令,以告知编译器提取嵌套的标头。
#include "target-pisa/pisa.h"
Just writing target-pisa/pisa.h
by itself isn't valid C code. target-pisa/pisa.h
自己编写target-pisa/pisa.h
并不是有效的C代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.