From a85d24ad1747c0cbc752966edc6e4acd6cffb032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 31 Oct 2019 11:43:49 +0100 Subject: [PATCH] Audio, GL: (attempt to) fix MinGW GCC warnings on static Windows builds. The CI doesn't have this configuration in the build matrix, so hoping it's doing what it's supposed to. --- src/Magnum/Audio/Context.cpp | 8 ++++++-- src/Magnum/GL/Context.cpp | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Audio/Context.cpp b/src/Magnum/Audio/Context.cpp index 9e531b3ef..8f9558350 100644 --- a/src/Magnum/Audio/Context.cpp +++ b/src/Magnum/Audio/Context.cpp @@ -142,8 +142,12 @@ CORRADE_VISIBILITY_EXPORT Context* currentContext = nullptr; #else /* On Windows the symbol is exported unmangled and then fetched via - GetProcAddress() to emulate weak linking. */ -extern "C" CORRADE_VISIBILITY_EXPORT Context* magnumAudioUniqueCurrentContext = nullptr; + GetProcAddress() to emulate weak linking. Using an extern "C" block instead + of just a function annotation because otherwise MinGW prints a warning: + '...' initialized and declared 'extern' (uh?) */ +extern "C" { + CORRADE_VISIBILITY_EXPORT Context* magnumAudioUniqueCurrentContext = nullptr; +} #endif #if !defined(MAGNUM_BUILD_STATIC) || defined(CORRADE_TARGET_WINDOWS) diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index c89b3eaa5..58209a75f 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -513,6 +513,7 @@ Context* currentContext = nullptr; called from. To avoid #ifdef hell in code below, the currentContext is redefined to return a value from this uniqueness-ensuring function. */ #if defined(CORRADE_TARGET_WINDOWS) && defined(MAGNUM_BUILD_STATIC) && !defined(CORRADE_TARGET_WINDOWS_RT) +extern "C" CORRADE_VISIBILITY_EXPORT Context*& magnumGLUniqueCurrentContext(); extern "C" CORRADE_VISIBILITY_EXPORT Context*& magnumGLUniqueCurrentContext() { return currentContext; }