Browse Source

Add a pair of headers to guard against intrusive Windows macros.

wip/core-clipp
Sam Hocevar 5 years ago
parent
commit
c1645f5e8b
20 changed files with 70 additions and 81 deletions
  1. +2
    -0
      include/lol/bigint
  2. +2
    -0
      include/lol/color
  3. +2
    -0
      include/lol/getopt
  4. +2
    -0
      include/lol/half
  5. +2
    -0
      include/lol/math
  6. +2
    -0
      include/lol/noise
  7. +0
    -12
      include/lol/private/math/functions.h
  8. +0
    -13
      include/lol/private/math/matrix.h
  9. +1
    -20
      include/lol/private/math/matrix.ipp
  10. +0
    -12
      include/lol/private/math/vector.h
  11. +20
    -0
      include/lol/private/pop_macros.h
  12. +25
    -0
      include/lol/private/push_macros.h
  13. +0
    -12
      include/lol/private/types/half.h
  14. +0
    -12
      include/lol/private/types/real.h
  15. +2
    -0
      include/lol/real
  16. +2
    -0
      include/lol/thread
  17. +2
    -0
      include/lol/transform
  18. +2
    -0
      include/lol/unit_test
  19. +2
    -0
      include/lol/utils
  20. +2
    -0
      include/lol/vector

+ 2
- 0
include/lol/bigint View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/types/bigint.h" #include "private/types/bigint.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/color View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/image/color.h" #include "private/image/color.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/getopt View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/sys/getopt.h" #include "private/sys/getopt.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/half View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/types/half.h" #include "private/types/half.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/math View File

@@ -12,8 +12,10 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/math/constants.h" #include "private/math/constants.h"
#include "private/math/functions.h" #include "private/math/functions.h"
#include "private/math/rand.h" #include "private/math/rand.h"
#include "private/math/polynomial.h" #include "private/math/polynomial.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/noise View File

@@ -17,7 +17,9 @@
// ——————————————— // ———————————————
// //


#include "private/push_macros.h"
#include "private/math/gradient.h" #include "private/math/gradient.h"
#include "private/math/perlin.h" #include "private/math/perlin.h"
#include "private/math/simplex.h" #include "private/math/simplex.h"
#include "private/pop_macros.h"



+ 0
- 12
include/lol/private/math/functions.h View File

@@ -24,13 +24,6 @@


#include <stdint.h> #include <stdint.h>


#if _MSC_VER
# pragma push_macro("min")
# pragma push_macro("max")
# undef min
# undef max
#endif

namespace lol namespace lol
{ {


@@ -167,8 +160,3 @@ template<typename T, typename T2 = T, typename DUMMY = LOL_T_UNSIGNED>
[[nodiscard]] static inline T2 sign(T x) { return (T)((T)0 < x); } [[nodiscard]] static inline T2 sign(T x) { return (T)((T)0 < x); }


} // namespace lol } // namespace lol

#if _MSC_VER
# pragma pop_macro("min")
# pragma pop_macro("max")
#endif

+ 0
- 13
include/lol/private/math/matrix.h View File

@@ -22,13 +22,6 @@
#include <ostream> // std::ostream #include <ostream> // std::ostream
#include <cmath> // std::fabs #include <cmath> // std::fabs


#if _WIN32
# pragma push_macro("near")
# pragma push_macro("far")
# undef near
# undef far
#endif

namespace lol namespace lol
{ {


@@ -610,9 +603,3 @@ template<typename T>
mat_t<T,4,4> const mat_t<T,4,4>::identity = mat_t<T,4,4>((T)1); mat_t<T,4,4> const mat_t<T,4,4>::identity = mat_t<T,4,4>((T)1);


} /* namespace lol */ } /* namespace lol */

#if _WIN32
# pragma pop_macro("near")
# pragma pop_macro("far")
#endif


+ 1
- 20
include/lol/private/math/matrix.ipp View File

@@ -16,17 +16,6 @@
#include <cmath> // std::tan #include <cmath> // std::tan
#include <algorithm> // std::max #include <algorithm> // std::max


#if _MSC_VER
# pragma push_macro("min")
# pragma push_macro("max")
# pragma push_macro("near")
# pragma push_macro("far")
# undef min
# undef max
# undef near
# undef far
#endif

namespace lol namespace lol
{ {


@@ -291,12 +280,4 @@ inline mat4 mat4::shifted_perspective(float fov_y, float screen_size,
mat4::translate(.0f, .0f, -dist_scr); mat4::translate(.0f, .0f, -dist_scr);
} }


} /* namespace lol */

#if _WIN32
# pragma pop_macro("min")
# pragma pop_macro("max")
# pragma pop_macro("near")
# pragma pop_macro("far")
#endif

} // namespace lol

+ 0
- 12
include/lol/private/math/vector.h View File

@@ -28,13 +28,6 @@


#include "ops.h" #include "ops.h"


#if _MSC_VER
# pragma push_macro("min")
# pragma push_macro("max")
# undef min
# undef max
#endif

namespace lol namespace lol
{ {


@@ -1438,8 +1431,3 @@ typedef ivec12 int12;
} // namespace lol } // namespace lol


#include "vector.ipp" #include "vector.ipp"

#if _MSC_VER
# pragma pop_macro("min")
# pragma pop_macro("max")
#endif

+ 20
- 0
include/lol/private/pop_macros.h View File

@@ -0,0 +1,20 @@
//
// Lol Engine
//
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

// Restore macros that push_macros.h disabled.

#if _MSC_VER
# pragma pop_macro("min")
# pragma pop_macro("max")
# pragma pop_macro("near")
# pragma pop_macro("far")
#endif

+ 25
- 0
include/lol/private/push_macros.h View File

@@ -0,0 +1,25 @@
//
// Lol Engine
//
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

// Undefine some intrusive macros from the Windows headers but allow
// to restore them afterwards if that’s what the user really wants.

#if _MSC_VER
# pragma push_macro("min")
# pragma push_macro("max")
# pragma push_macro("near")
# pragma push_macro("far")
# undef min
# undef max
# undef near
# undef far
#endif

+ 0
- 12
include/lol/private/types/half.h View File

@@ -28,13 +28,6 @@
namespace lol namespace lol
{ {


#if _WIN32
# pragma push_macro("near")
# pragma push_macro("far")
# undef near
# undef far
#endif

namespace half_ops { struct base {}; } namespace half_ops { struct base {}; }


class [[nodiscard]] half class [[nodiscard]] half
@@ -335,8 +328,3 @@ DECLARE_HALF_BOOL_OPS(<=)
} // namespace half_ops } // namespace half_ops


} // namespace lol } // namespace lol

#if _WIN32
# pragma pop_macro("near")
# pragma pop_macro("far")
#endif

+ 0
- 12
include/lol/private/types/real.h View File

@@ -24,13 +24,6 @@
#include <string> // std::string #include <string> // std::string
#include <stdint.h> // int64_t etc. #include <stdint.h> // int64_t etc.


#if _MSC_VER
# pragma push_macro("min")
# pragma push_macro("max")
# undef min
# undef max
#endif

namespace lol namespace lol
{ {


@@ -266,8 +259,3 @@ typedef real_t<uint32_t> real;
} // namespace lol } // namespace lol


#include "real.ipp" #include "real.ipp"

#if _MSC_VER
# pragma pop_macro("min")
# pragma pop_macro("max")
#endif

+ 2
- 0
include/lol/real View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/types/real.h" #include "private/types/real.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/thread View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/sys/threading.h" #include "private/sys/threading.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/transform View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/math/transform.h" #include "private/math/transform.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/unit_test View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/lolunit.h" #include "private/lolunit.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/utils View File

@@ -12,9 +12,11 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/features.h" #include "private/features.h"
#include "private/base/env.h" #include "private/base/env.h"
#include "private/base/string.h" #include "private/base/string.h"
#include "private/base/containers.h" #include "private/base/containers.h"
#include "private/base/misc.h" #include "private/base/misc.h"
#include "private/pop_macros.h"



+ 2
- 0
include/lol/vector View File

@@ -12,5 +12,7 @@


#pragma once #pragma once


#include "private/push_macros.h"
#include "private/math/vector.h" #include "private/math/vector.h"
#include "private/pop_macros.h"



Loading…
Cancel
Save