From 58855d3d342223378689995fb10026b032392f27 Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 25 Mar 2023 09:10:28 +1000 Subject: [PATCH] Fix some pedantic warnings when compiling with GCC. --- CHANGES.md | 1 + miniaudio.h | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 571d4d5d..2c67810e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ v0.11.12 - TBD ===================== +* Fix some pedantic warnings when compiling with GCC. * A safety change for custom VFS implementations. The `pBytesRead` parameter on the onRead callback is now pre-initialized to zero. diff --git a/miniaudio.h b/miniaudio.h index 6e4e5566..0ce2ecc4 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -3799,7 +3799,18 @@ typedef double ma_double; typedef void* ma_handle; typedef void* ma_ptr; + +/* +ma_proc is annoying because when compiling with GCC we get pendantic warnings about converting +between `void*` and `void (*)()`. We can't use `void (*)()` with MSVC however, because we'll get +warning C4191 about "type cast between incompatible function types". To work around this I'm going +to use a different data type depending on the compiler. +*/ +#if defined(__GNUC__) +typedef void (*ma_proc)(void); +#else typedef void* ma_proc; +#endif #if defined(_MSC_VER) && !defined(_WCHAR_T_DEFINED) typedef ma_uint16 wchar_t;