C++ 无法在C+;中包含头文件+;
我的代码如下所示:C++ 无法在C+;中包含头文件+;,c++,compiler-errors,include,C++,Compiler Errors,Include,我的代码如下所示: #include <GLFW\glfw3.h> // define the function's prototype typedef void (*GL_GENBUFFERS) (GLsizei, GLuint*); // find the function and assign it to a function pointer GL_GENBUFFERS glGenBuffers = (GL_GENBUFFERS)wglGetProcAddress(&qu
#include <GLFW\glfw3.h>
// define the function's prototype
typedef void (*GL_GENBUFFERS) (GLsizei, GLuint*);
// find the function and assign it to a function pointer
GL_GENBUFFERS glGenBuffers = (GL_GENBUFFERS)wglGetProcAddress("glGenBuffers");
// function can now be called as normal
unsigned int buffer;
glGenBuffers(1, &buffer);
.
├── include
│ ├── glad
│ │ └── glad.h
│ ├── GLFW
│ │ ├── glfw3.h
│ │ └── glfw3native.h
│ └── KHR
│ └── khrplatform.h
├── test
└── test.cpp
我的文件夹如下所示:
#include <GLFW\glfw3.h>
// define the function's prototype
typedef void (*GL_GENBUFFERS) (GLsizei, GLuint*);
// find the function and assign it to a function pointer
GL_GENBUFFERS glGenBuffers = (GL_GENBUFFERS)wglGetProcAddress("glGenBuffers");
// function can now be called as normal
unsigned int buffer;
glGenBuffers(1, &buffer);
.
├── include
│ ├── glad
│ │ └── glad.h
│ ├── GLFW
│ │ ├── glfw3.h
│ │ └── glfw3native.h
│ └── KHR
│ └── khrplatform.h
├── test
└── test.cpp
编译器错误为:
/home/user/git/tfg_gui/test.cpp:1:10: fatal error: GLFW\glfw3.h: No such file or directory
1 | #include <GLFW\glfw3.h>
| ^~~~~~~~~~~~~~
compilation terminated.
/home/user/git/tfg_gui/test.cpp:1:10:致命错误:GLFW\glfw3.h:没有这样的文件或目录
1 |#包括
| ^~~~~~~~~~~~~~
编译终止。
我认为我犯了一个非常愚蠢的错误,但我已经花了太多时间试图找到它。可能是因为我假设某件事是以一种不正确的方式完成的
谢谢 在\include
的路径中使用反斜杠\
:
#include <GLFW\glfw3.h>
由于正向斜杠也适用于Windows,因此始终使用它是一个好习惯。在\include
的路径中,使用反向斜杠\
:
#include <GLFW\glfw3.h>
由于正斜杠也适用于Windows,因此始终使用它是一个好习惯。如果使用反斜杠,请将其转换为正斜杠
#包括
反斜杠是转义字符,用于将键盘上始终可用的普通字母(n
,a
,等等)转换为无法读取或看到的特殊字符(LF
,Beep
,等等)。在本例中,编译器将文件名视为
GLFW[unknown character]lfw3.h
,但该文件不存在。这就是错误的来源。如果使用反斜杠,请将其转换为正斜杠
#包括
反斜杠是转义字符,用于将键盘上始终可用的普通字母(n
,a
,等等)转换为无法读取或看到的特殊字符(LF
,Beep
,等等)。在本例中,编译器将文件名视为
GLFW[unknown character]lfw3.h
,但该文件不存在。这就是错误的来源。您能添加编译器错误吗?当然,我忘了添加。我已经编辑了这个问题。你能添加编译器错误吗?当然,我忘记了。我已经编辑了这个问题。