forked from icaven/glm
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
I have a header file vector4.h which contains the following:
#ifndef SRC_COMMON_VECTOR4_H
#define SRC_COMMON_VECTOR4_H
#include <glm/vec4.hpp>
#include <glm/gtc/quaternion.hpp>
namespace glm {
extern template struct qua<float>;
extern template struct vec<4, float, glm::defaultp>;
extern template struct vec<4, long long, glm::defaultp>;
extern template struct vec<4, long, glm::defaultp>;
extern template struct vec<4, int, glm::defaultp>;
extern template struct vec<4, unsigned long long, glm::defaultp>;
extern template struct vec<4, unsigned long, glm::defaultp>;
extern template struct vec<4, unsigned int, glm::defaultp>;
extern template struct vec<4, short, glm::defaultp>;
extern template struct vec<4, unsigned short, glm::defaultp>;
extern template struct vec<4, signed char, glm::defaultp>;
extern template struct vec<4, unsigned char, glm::defaultp>;
}
namespace raid {
namespace math = ::glm;
using quat = math::qua<float>;
using float4 = math::vec<4, float, glm::defaultp>;
using longlong4 = math::vec<4, long long, glm::defaultp>;
using long4 = math::vec<4, long, glm::defaultp>;
using int4 = math::vec<4, int, glm::defaultp>;
using ulonglong4 = math::vec<4, unsigned long long, glm::defaultp>;
using ulong4 = math::vec<4, unsigned long, glm::defaultp>;
using uint4 = math::vec<4, unsigned int, glm::defaultp>;
using short4 = math::vec<4, short, glm::defaultp>;
using ushort4 = math::vec<4, unsigned short, glm::defaultp>;
using byte4 = math::vec<4, signed char, glm::defaultp>;
using ubyte4 = math::vec<4, unsigned char, glm::defaultp>;
} // namespace raid
#endif// SRC_COMMON_VECTOR4_H
I also have a corresponding vector4.cpp:
#include "common/vector4.h"
namespace glm {
template struct qua<float>;
template struct vec<4, float, glm::defaultp>;
template struct vec<4, long long, glm::defaultp>;
template struct vec<4, long, glm::defaultp>;
template struct vec<4, int, glm::defaultp>;
template struct vec<4, unsigned long long, glm::defaultp>;
template struct vec<4, unsigned long, glm::defaultp>;
template struct vec<4, unsigned int, glm::defaultp>;
template struct vec<4, short, glm::defaultp>;
template struct vec<4, unsigned short, glm::defaultp>;
template struct vec<4, signed char, glm::defaultp>;
template struct vec<4, unsigned char, glm::defaultp>;
}However, the explicit instantiations do not seem to work (as I would expect them to).
Because whenever vector4.h gets included, glm automatically instantiates vec<4,T> in every combination.
I would expect my compiler to generate only one instantiation for the variations I specified in vector4.cpp.
Here is a trace of a file.
As you can see, the compiler (clang-cl in my case) instantiates all vector4's:

Is there a way to avoid this?
These are my glm compile defines:
GLM_FORCE_MESSAGES
GLM_FORCE_CXX98
GLM_FORCE_PURE
GLM_FORCE_LEFT_HANDED
GLM_FORCE_SWIZZLE
GLM_ENABLE_EXPERIMENTAL
GLM_FORCE_INLINE
GLM_FORCE_DEPTH_ZERO_TO_ONE
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels