Reputation: 194
There seems to be something wrong with accessing namespaces in header files. The best way to explain this is by example:
I'm getting a compiler error for doing this:
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"
Here's the error:
'glm' is not a class or namespace name
'projection': unknown override specifier
missing type specifier - int assumed. Note: C++ does not support default-int
However, doing this is fine:
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;
What I'm stumped by is the fact that the namespace can't be found inside the header file although it works on the cpp file.
Visual Studio recognizes that the namespace exists (no underline in editor) but when I compile it suddenly doesn't exist.
Upvotes: 2
Views: 252
Reputation: 769
It is not available in your header file, because you didn't include it:
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
Upvotes: 2