Windows: Fix compilation warnings with GCC 11.2.1

This commit is contained in:
Rémi Verschelde 2021-11-10 15:09:56 +01:00
parent e317e34c15
commit b727061ce0
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 17 additions and 5 deletions

View File

@ -121,6 +121,12 @@ const IID IID_IAudioCaptureClient = __uuidof(IAudioCaptureClient);
static bool default_render_device_changed = false; static bool default_render_device_changed = false;
static bool default_capture_device_changed = false; static bool default_capture_device_changed = false;
// Silence warning due to a COM API weirdness (GH-35194).
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
class CMMNotificationClient : public IMMNotificationClient { class CMMNotificationClient : public IMMNotificationClient {
LONG _cRef = 1; LONG _cRef = 1;
IMMDeviceEnumerator *_pEnumerator = nullptr; IMMDeviceEnumerator *_pEnumerator = nullptr;
@ -162,7 +168,7 @@ public:
HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId) { HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId) {
return S_OK; return S_OK;
}; }
HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId) { HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId) {
return S_OK; return S_OK;
@ -189,6 +195,10 @@ public:
} }
}; };
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
static CMMNotificationClient notif_client; static CMMNotificationClient notif_client;
Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_capture, bool reinit) { Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_capture, bool reinit) {
@ -373,7 +383,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_capture ? REFTIMES_PER_SEC : 0, 0, pwfex, nullptr); hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_capture ? REFTIMES_PER_SEC : 0, 0, pwfex, nullptr);
ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_CANT_OPEN, "WASAPI: Initialize failed with error 0x" + String::num_uint64(hr, 16) + "."); ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_CANT_OPEN, "WASAPI: Initialize failed with error 0x" + String::num_uint64(hr, 16) + ".");
UINT32 max_frames; UINT32 max_frames;
HRESULT hr = p_device->audio_client->GetBufferSize(&max_frames); hr = p_device->audio_client->GetBufferSize(&max_frames);
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN); ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
// Due to WASAPI Shared Mode we have no control of the buffer size // Due to WASAPI Shared Mode we have no control of the buffer size

View File

@ -42,6 +42,11 @@
#include "drivers/gles3/rasterizer_gles3.h" #include "drivers/gles3/rasterizer_gles3.h"
#endif #endif
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define GetProcAddress (void *)GetProcAddress
#endif
static String format_error_message(DWORD id) { static String format_error_message(DWORD id) {
LPWSTR messageBuffer = nullptr; LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,

View File

@ -197,9 +197,6 @@ Error GLManager_Windows::window_create(DisplayServer::WindowID p_window_id, HWND
return FAILED; return FAILED;
} }
// the display could be invalid .. check NYI
GLDisplay &gl_display = _displays[win.gldisplay_id];
// make current // make current
window_make_current(_windows.size() - 1); window_make_current(_windows.size() - 1);