floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
7.11k stars 501 forks source link

Fix _saudio_backend_shutdown for _SAUDIO_APPLE #1110

Closed badlogic closed 2 months ago

badlogic commented 2 months ago

The code path tries to return void. Does not compile for obvious reasons.

floooh commented 2 months ago

Whoops interesting, do you get a compile error with that (if yes, with which compiler / build settings)? Even though it's an oversight, AFAIK it's valid C/C++,

For instance the sokol_gfx.h C++ wrappers also return void:

https://github.com/floooh/sokol/blob/1eb96dd0f96b9ea73065f9078244c2255c2b75d9/sokol_gfx.h#L4333-L4335

floooh commented 2 months ago

...merged, thanks!

Would still be good to know why that exactly caused the trouble on your end.

badlogic commented 2 months ago

Returning a value from a void function makes the compiler sad. See also the "missing" return statements for the other code paths in that function.

On Sun, Sep 15, 2024, 18:16 Andre Weissflog @.***> wrote:

...merged, thanks!

Would still be good to know why that caused trouble on your end.

— Reply to this email directly, view it on GitHub https://github.com/floooh/sokol/pull/1110#issuecomment-2351660884, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5QBBFUDTSCPPDY7H7KL3ZWWXEBAVCNFSM6AAAAABOH4NDMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGY3DAOBYGQ . You are receiving this because you authored the thread.Message ID: @.***>

badlogic commented 2 months ago

Apologies, only saw your last message due to email usage...

I have -Werror,-Wpedantic on, which will complain, even if it's valid as per spec.

[build] sokol_audio.h:2476:9: error: void function '_saudio_backend_shutdown' should not return void expression [-Werror,-Wpedantic]
[build]         return _saudio_coreaudio_backend_shutdown();
[build]         ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Xcode Clang, pretty recent iirc.

➜  clang --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.5.0
Thread model: posix
floooh commented 2 months ago

Ah ok. Building with -Wpedantic is brave, I'm surprised that even works tbh ;)

I build the sokol test code with -Wall -Wextra -Werror -Wsign-conversion -Wstrict-prototypes, but specifically left out -Wpedantic (for GCC and Clang).

And for Windows: /W4 /WX /D_CRT_SECURE_NO_WARNINGS.

floooh commented 2 months ago

I wonder now if returning void might be valid C++, but not valid C - would be another subtle difference ;)

badlogic commented 2 months ago

Could be. My code base is C11, haven't tested with C++. Probably doesn't matter, because Sokol also supports MSVC :)

On Sun, Sep 15, 2024, 18:52 Andre Weissflog @.***> wrote:

I wonder now if returning void might be valid C++, but not valid C - would be another subtle difference ;)

— Reply to this email directly, view it on GitHub https://github.com/floooh/sokol/pull/1110#issuecomment-2351674044, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5QBHNWV3MUVCN7MAODBLZWW3MBAVCNFSM6AAAAABOH4NDMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGY3TIMBUGQ . You are receiving this because you authored the thread.Message ID: @.***>