访问头文件中的名称空间似乎有问题。最好的解释方式是通过示例:
我在执行此操作时遇到编译器错误:
Game.h:
#pragma once
struct Game
{
//some other stuff here
private:
glm::mat4 projection;
};
Game.cpp:
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "Game.h"
这是错误:
'glm' is not a class or namespace name
'projection': unknown override specifier
missing type specifier - int assumed. Note: C++ does not support default-int
但是,这样做很好:
Game.h:
#pragma once
struct Game
{
//some other stuff here
};
Game.cpp:
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "Game.h"
glm::mat4 projection;
令我感到困扰的是,尽管在命名空间文件中可以使用命名空间,但是在头文件中找不到命名空间。
Visual Studio识别名称空间存在(编辑器中没有下划线),但是在编译时突然不存在该名称空间。
它在您的头文件中不可用,因为您没有包括它:
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句