简体   繁体   中英

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.

Say I have a file named "machine.h", its content is 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"; 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".

Assume for some reason I cannot simply copy and paste the code from "pisa.h" to "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". Instead, git bash interprets target-pisa/pisa.h as C code (if I am not mistaken); 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

I have checked that almost all .c files in the working directory have #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.

I tried to reinstall git bash in order to see if the problem can be solved, but it didn't.

All in all, I want to build the program successfully by using make command in git bash.

machine.h needs to have an #include directive to tell the compiler to pull in the nested header.

#include "target-pisa/pisa.h"

Just writing target-pisa/pisa.h by itself isn't valid C code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM