diff --git a/doc/changelog.dox b/doc/changelog.dox index 86c83df4d..22c2c03b5 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1235,6 +1235,9 @@ See also: - Fixed a GCC warning about mismatched symbol export in @ref GL::Mesh on static builds where user code didn't compile with `-fvisiblity=hidden` (see [mosra/magnum#683](https://github.com/mosra/magnum/issues/683)) +- Undefining the `near` and `far` macros on Windows in a more robust way + (see [mosra/magnum#689](https://github.com/mosra/magnum/issues/689) and + [mosra/magnum#690](https://github.com/mosra/magnum/pull/690)) @subsection changelog-latest-bugfixes Bug fixes diff --git a/doc/credits.dox b/doc/credits.dox index 72aa6dc58..85aedd2b5 100644 --- a/doc/credits.dox +++ b/doc/credits.dox @@ -86,6 +86,8 @@ Are the below lists missing your name or something's wrong? - **Aaron Gokaslan** ([\@Skylion007](https://github.com/Skylion007)) --- Emscripten LTO support, various minor code modernization, typo fixes - **[\@abgita](https://github.com/abgita)** --- minor typo fixes +- **Samuel Longchamps** ([\@ak-slongchamps](https://github.com/ak-slongchamps)) + --- Windows build fixes - **Alan Jefferson** ([\@alanjfs](https://github.com/alanjfs)) --- extensive usability and first-time-use feedback - **[\@Alan-FGR](https://github.com/Alan-FGR)** --- documentation fixes diff --git a/src/Magnum/Math/Frustum.h b/src/Magnum/Math/Frustum.h index 52b890c5b..25c95e3df 100644 --- a/src/Magnum/Math/Frustum.h +++ b/src/Magnum/Math/Frustum.h @@ -7,6 +7,7 @@ 2020, 2021, 2022, 2023, 2024, 2025, 2026 Vladimír Vondruš Copyright © 2016, 2020 Jonathan Hale + Copyright © 2026 Samuel Longchamps Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -42,11 +43,12 @@ #include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Vector4.h" -#ifdef CORRADE_TARGET_WINDOWS /* I so HATE windef.h */ -/* far/near and FAR/NEAR are defined by minwindef.h, but the former are used by this file as variables. - While they are all empty defines, the Windows headers expect FAR/NEAR to be defined and so we redefine them here. - far/near are left undefined because they are not used directly in Windows headers. - */ +#ifdef CORRADE_TARGET_WINDOWS +/* far/near and FAR/NEAR are defined by minwindef.h, with the latter being + aliases to the former, but the lowercase variants are used by this file as + identifiers. While they all ultimately expand to nothing, the Windows + headers expect FAR/NEAR to be defined and so we redefine them here. far/near + are left undefined because they are not used directly in Windows headers. */ #undef near #undef NEAR #define NEAR diff --git a/src/Magnum/Math/Matrix4.h b/src/Magnum/Math/Matrix4.h index 07ec11dd6..b3a60e1d3 100644 --- a/src/Magnum/Math/Matrix4.h +++ b/src/Magnum/Math/Matrix4.h @@ -6,6 +6,7 @@ Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026 Vladimír Vondruš + Copyright © 2026 Samuel Longchamps Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -37,11 +38,12 @@ #include "Magnum/Math/Matrix.h" #include "Magnum/Math/Vector4.h" -#ifdef CORRADE_TARGET_WINDOWS /* I so HATE windef.h */ -/* far/near and FAR/NEAR are defined by minwindef.h, but the former are used by this file as variables. - While they are all empty defines, the Windows headers expect FAR/NEAR to be defined and so we redefine them here. - far/near are left undefined because they are not used directly in Windows headers. - */ +#ifdef CORRADE_TARGET_WINDOWS +/* far/near and FAR/NEAR are defined by minwindef.h, with the latter being + aliases to the former, but the lowercase variants are used by this file as + identifiers. While they all ultimately expand to nothing, the Windows + headers expect FAR/NEAR to be defined and so we redefine them here. far/near + are left undefined because they are not used directly in Windows headers. */ #undef near #undef NEAR #define NEAR diff --git a/src/Magnum/SceneGraph/Camera.h b/src/Magnum/SceneGraph/Camera.h index ee442e2fe..abda2b31a 100644 --- a/src/Magnum/SceneGraph/Camera.h +++ b/src/Magnum/SceneGraph/Camera.h @@ -6,6 +6,7 @@ Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026 Vladimír Vondruš + Copyright © 2026 Samuel Longchamps Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -35,11 +36,12 @@ #include "Magnum/SceneGraph/AbstractFeature.h" #include "Magnum/SceneGraph/visibility.h" -#ifdef CORRADE_TARGET_WINDOWS /* I so HATE windef.h */ -/* far/near and FAR/NEAR are defined by minwindef.h, but the former are used by this file as variables. - While they are all empty defines, the Windows headers expect FAR/NEAR to be defined and so we redefine them here. - far/near are left undefined because they are not used directly in Windows headers. - */ +#ifdef CORRADE_TARGET_WINDOWS +/* far/near and FAR/NEAR are defined by minwindef.h, with the latter being + aliases to the former, but the lowercase variants are used by this file as + identifiers. While they all ultimately expand to nothing, the Windows + headers expect FAR/NEAR to be defined and so we redefine them here. far/near + are left undefined because they are not used directly in Windows headers. */ #undef near #undef NEAR #define NEAR diff --git a/src/Magnum/Trade/CameraData.h b/src/Magnum/Trade/CameraData.h index 5937d0a43..6babbc00a 100644 --- a/src/Magnum/Trade/CameraData.h +++ b/src/Magnum/Trade/CameraData.h @@ -6,6 +6,7 @@ Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026 Vladimír Vondruš + Copyright © 2026 Samuel Longchamps Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -34,11 +35,12 @@ #include "Magnum/Math/Vector2.h" #include "Magnum/Trade/visibility.h" -#ifdef CORRADE_TARGET_WINDOWS /* I so HATE windef.h */ -/* far/near and FAR/NEAR are defined by minwindef.h, but the former are used by this file as variables. - While they are all empty defines, the Windows headers expect FAR/NEAR to be defined and so we redefine them here. - far/near are left undefined because they are not used directly in Windows headers. - */ +#ifdef CORRADE_TARGET_WINDOWS +/* far/near and FAR/NEAR are defined by minwindef.h, with the latter being + aliases to the former, but the lowercase variants are used by this file as + identifiers. While they all ultimately expand to nothing, the Windows + headers expect FAR/NEAR to be defined and so we redefine them here. far/near + are left undefined because they are not used directly in Windows headers. */ #undef near #undef NEAR #define NEAR