遇到麻烦,包括标题文件
我只能使用将其添加到C:\ sdl2-w64 \ include中的标头文件,但是我无法将其链接到项目文件夹中的Include文件夹。
例如:我有一个名为“ myproject”的文件夹,它位于c:\ users \ user \ desktop \ myproject,在项目文件夹中,有一个“ inclage”文件夹,位于\ myProject \ inclage inclate \ inclage,然后我添加一个名为“标头文件” “ head.h”到包括路径。在我的代码中,我使用#include< head.h>
,然后我获得错误无法打开源文件“ head.h” ,但是如果我添加head.h c:\ sdl2-w64 \ include它的工作原理很好。
有人知道如何在我的项目文件夹中包含“包含文件夹”?
I can only use header files that I add to C:\SDL2-w64\include, but I Can't get it to link to the include folder inside my project folder.
for example: I have a folder called "MyProject" and its located at C:\Users\User\Desktop\MyProject, inside the project folder there is an "Include" folder located at \MyProject\Include then I add a header file called "head.h" to the Include path. in my code I use #include <head.h>
, I then get the error cannot open source file "head.h", but if I add head.h to C:\SDL2-w64\include it works perfectly fine.
anyone know how to include the Include folder located in my project folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设执行包含的文件位于
c:\ users \ user \ desktop \ myproject
,请尝试使用#include“ include/head.h”
。这是因为在您的包含中,使用引号(“”)和角度括号(&lt;&gt;)之间存在区别。原因在以下答案中解释: https://stackoverflow.com/a/3162067/190999501
借助大多数编译器,
#include“ blah.h”
将首先在本地目录中搜索,然后从路径变量中的内容到达的内容,#include&lt; blah。 H&gt;
将仅在路径中的内容中搜索。我猜想c:\ sdl2-w64 \ include
在您的路径中。这可能就是为什么当您将标头文件移至该位置时,它可以找到它。Assuming the file doing the including is located at
C:\Users\User\Desktop\MyProject
, try using#include "Include/head.h"
. This is because there is a difference between using quotations ("") and angle brackets (<>) in your includes.The reason is explained in this answer: https://stackoverflow.com/a/3162067/19099501
But to summarize it, with most compilers,
#include "blah.h"
will search in the local directory first, and then the stuff it can reach from what's in your PATH variable, and#include <blah.h>
will search from what's in PATH only. I am guessing thatC:\SDL2-w64\include
is in your PATH. That is probably why when you moved the header file to that location, it was able to find it.