diff --git a/src/singles/MagnumMath.hpp b/src/singles/MagnumMath.hpp index fd228f8c2..50c32704b 100644 --- a/src/singles/MagnumMath.hpp +++ b/src/singles/MagnumMath.hpp @@ -447,7 +447,17 @@ typedef Math::Frustum Frustumd; // TODO: DynamicMatrixIntegration (separate library because of StridedArrayView) #include "Magnum/EigenIntegration/GeometryIntegration.h" #endif -#ifdef MAGNUM_MATH_IMPLEMENTATION +/* The extra guard has to be here to prevent double definitions in cases like + + #define MAGNUM_MATH_IMPLEMENTATION + #include + #include + + where MagnumMathBatch.hpp contains `#include ` again. Note + that even the stb_* libs don't handle this -- including them twice with the + implementation macro defined *will* lead to double definitions. */ +#if defined(MAGNUM_MATH_IMPLEMENTATION) && !defined(MagnumMath_hpp_implementation) +#define MagnumMath_hpp_implementation // {{ includes }} #include "Magnum/Math/Functions.cpp" #include "Magnum/Math/Packing.cpp" diff --git a/src/singles/MagnumMathBatch.hpp b/src/singles/MagnumMathBatch.hpp index 006bca91d..c4b119998 100644 --- a/src/singles/MagnumMathBatch.hpp +++ b/src/singles/MagnumMathBatch.hpp @@ -67,6 +67,17 @@ // TODO ColorBatch once it's more useful #include "Magnum/Math/FunctionsBatch.h" #include "Magnum/Math/PackingBatch.h" -#ifdef MAGNUM_MATH_BATCH_IMPLEMENTATION +/* The extra guard has to be here to prevent double definitions in cases like + + #define MAGNUM_MATH_BATCH_IMPLEMENTATION + #include + #include + + where a hypothetical SomeOtherLib.h contains `#include ` + again. Note that even the stb_* libs don't handle this -- including them + twice with the implementation macro defined *will* lead to double + definitions. */ +#if defined(MAGNUM_MATH_BATCH_IMPLEMENTATION) && !defined(MagnumMathBatch_hpp_implementation) +#define MagnumMathBatch_hpp_implementation #include "Magnum/Math/PackingBatch.cpp" #endif diff --git a/src/singles/MagnumMeshTools.hpp b/src/singles/MagnumMeshTools.hpp index 725645a31..2da8e990e 100644 --- a/src/singles/MagnumMeshTools.hpp +++ b/src/singles/MagnumMeshTools.hpp @@ -109,7 +109,18 @@ template using Array4 = StaticArray<4, T>; // TODO FlipNormals? // TODO GenerateNormals? // TODO RemoveDuplicates? -#ifdef MAGNUM_MESHTOOLS_IMPLEMENTATION +/* The extra guard has to be here to prevent double definitions in cases like + + #define MAGNUM_MESHTOOLS_IMPLEMENTATION + #include + #include + + where a hypothetical SomeOtherLib.h contains `#include ` + again. Note that even the stb_* libs don't handle this -- including them + twice with the implementation macro defined *will* lead to double + definitions. */ +#if defined(MAGNUM_MESHTOOLS_IMPLEMENTATION) && !defined(MagnumMeshTools_hpp_implementation) +#define MagnumMeshTools_hpp_implementation // {{includes}} #if !defined(CORRADE_ASSERT_UNREACHABLE) && !defined(NDEBUG) #include