From 8048b65964e1bb171b637c6edd2699b43f45e2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 30 Nov 2023 13:41:21 +0100 Subject: [PATCH] Platform: fix build with Emscripten 3.1.49+. --- doc/changelog.dox | 2 ++ src/Magnum/Platform/EmscriptenApplication.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/changelog.dox b/doc/changelog.dox index 464dbc85c..653dd8009 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1022,6 +1022,8 @@ See also: dependencies without risking breakages when new Emscripten versions make more JS API functions optional, and circumvents the need for users to specify `-s EXPORTED_FUNCTIONS` on their side. See [mosra/magnum#619](https://github.com/mosra/magnum/issues/619). +- Fixed build of @ref Platform::EmscriptenApplication on Emscripten 3.1.49 + and newer (see [mosra/magnum#631](https://github.com/mosra/magnum/issues/631)) @subsection changelog-latest-bugfixes Bug fixes diff --git a/src/Magnum/Platform/EmscriptenApplication.h b/src/Magnum/Platform/EmscriptenApplication.h index 9c583e6e3..92605426e 100644 --- a/src/Magnum/Platform/EmscriptenApplication.h +++ b/src/Magnum/Platform/EmscriptenApplication.h @@ -57,14 +57,29 @@ #endif #if defined(CORRADE_TARGET_EMSCRIPTEN) || defined(DOXYGEN_GENERATING_OUTPUT) +/* The __EMSCRIPTEN_major__ etc macros used to be passed implicitly, version + 3.1.4 moved them to a version header and version 3.1.23 dropped the + backwards compatibility. To work consistently on all versions, including the + header only if the version macros aren't present. + https://github.com/emscripten-core/emscripten/commit/f99af02045357d3d8b12e63793cef36dfde4530a + https://github.com/emscripten-core/emscripten/commit/f76ddc702e4956aeedb658c49790cc352f892e4c */ +#ifndef __EMSCRIPTEN_major__ +#include +#endif #ifndef DOXYGEN_GENERATING_OUTPUT struct EmscriptenKeyboardEvent; struct EmscriptenMouseEvent; struct EmscriptenWheelEvent; struct EmscriptenUiEvent; + +/* The typedef changed in 3.1.49, https://github.com/emscripten-core/emscripten/commit/40cbc2164400a7c27218b9655f1830bfc882bb01 */ +#if __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 30149 +typedef std::intptr_t EMSCRIPTEN_WEBGL_CONTEXT_HANDLE; +#else typedef int EMSCRIPTEN_WEBGL_CONTEXT_HANDLE; #endif +#endif namespace Magnum { namespace Platform {