mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

Unused function warning when compiling miniaudio_split/miniaudio.c #732

Closed mlabbe closed 1 year ago

mlabbe commented 1 year ago

I am receiving many unused functiotn warnings when compiling the split miniaudio.c with -Wall on clang 16 on Windows. This is because a lot of functions are declared static.

In my fork I made this simple change: https://github.com/mackron/miniaudio/commit/bf4d4666d4d037b262a093d562dcd48edea94861

Unclear how you'd like to go about seeing a PR for the split miniaudio files, or how the split files are generated from the single header, but happy to do so with instruction.

mackron commented 1 year ago

Thanks. It should compile clean with default options. Are you using any compile time defines like -DMA_NO_DECODING or anything? Can you post the warnings?

In the past this warning has been a huge pain, and I have indeed been tempted to just wrap the entire library like your suggestion, but I've resisted so far.

Just FYI, the split version is auto-generated using a tool, so ideally the change would be in the main miniaudio.h file. But let's first see the warnings and defines you're using before doing a PR.

mlabbe commented 1 year ago

Apologies - the specific warning is coming in through -Wextra instead of -Wall on my end. That said, I am able to reproduce this without any compile time defines. Let me know if you'd still like to see the compiler output from -Wextra, or you can close this as a non-issue if warnings-free -Wextra is not supported.

mackron commented 1 year ago

Yep -Wextra is definitely supported. I support -Wall -Wextra -Wpedantic.

I was able to replicate this, I think. I was getting these:

Z:/dev/mackron/miniaudio/miniaudio.h:18666:13: warning: 'ma_device__on_notification_interruption_ended' defined but not used [-Wunused-function]
 static void ma_device__on_notification_interruption_ended(ma_device* pDevice)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Z:/dev/mackron/miniaudio/miniaudio.h:18661:13: warning: 'ma_device__on_notification_interruption_began' defined but not used [-Wunused-function]
 static void ma_device__on_notification_interruption_began(ma_device* pDevice)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Are these the only ones you were getting? If you were getting more, can you post them here?

I've fixed these in the dev branch, but only in the main miniaudio.h file. The split version does not include the fix yet (I only update that when I do new releases, which I need to get done soon anyway).