简体   繁体   中英

Header files not found in Atom editor for C++

I'm trying to use the Atom editor for writing C++ code. I want to use the linter-gcc package, but I keep getting the error that it cannot find my header files.

I have tried going into the linter-gcc settings and adding in the GCC Include Paths the following:

-/, ./, ./include

Here are my linter-gcc settings currently:

linter-gcc 设置

and you can see here the editor where the issue arises and on the left is the directory I'm working in

编辑

https://github.com/AtomLinter/linter-gcc/issues/61

You have to add the project root to your include directories. If you simply copy and paste the linter-gcc command into the terminal, you'll see the same error. The solution is to add the path to your include paths to the GCC Include paths setting. So if you have in your project root a folder called include that contains your header files, you need ti write ./include in your GCC Include paths settings. Generally, it's good practice to put your header files in a folder called include in your project root. Then you can simply write ./include in your GCC Include paths setting so the compiler finds the header files.

In sumary, try to put only ./include in your gcc-linter package settings, in both fields for includes: gcc-linter settings

After that, go back to your file and click cntrl+s or just save it again. It will run the linter again and the issue will be gone (maybe you did not run the linter again after adding the includes as you showed in your comment, so that is why you kept seeing the error)

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