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

compile error in Xcode for iOS #770

Closed digitalgust closed 1 year ago

digitalgust commented 1 year ago

Xcode 13.2 iOS 9+

Xcode compile miniaudio.h error:

/Users/user01/Documents/GitHub/miniJVM/mobile/c/gui/minial/miniaudio.h:33935:13: Implicit declaration of function 'ma_device__on_notification_interruption_began' is invalid in C99

/Users/user01/Documents/GitHub/miniJVM/mobile/c/gui/minial/miniaudio.h:33941:13: Implicit declaration of function 'ma_device__on_notification_interruption_ended' is invalid in C99

These two function not found . they defined at there

截屏2023-11-08 上午8 34 36

but there isn't a micro "MA_APPLE_MOBILE" defined

mackron commented 1 year ago

MA_APPLE_MOBILE is defined in this block:

#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
    #define MA_APPLE_MOBILE // <-- MA_APPLE_MOBILE defined here
    #if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
        #define MA_APPLE_TV
    #endif
    #if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
        #define MA_APPLE_WATCH
    #endif
    ...
#else
    #define MA_APPLE_DESKTOP
#endif

It's currently using #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1. You'll need to check your compiler settings as to why it's different to this. If you can determine how to properly detect the iOS build with your build environment you can post it here and I can consider adding it to that section.

digitalgust commented 1 year ago

miniaudio - v0.11.19 - 2023-11-04 not work . miniaudio - v0.11.9 - 2022-04-20 work.

there is no change in my project , but only updated the miniaudio.h .

Moving these two functions after this definition will result in normal compilation. The issue here is that there is a usage of a macro definition before its definition. I have noticed that there are other macro definitions in the code that also have similar situations.

截屏2023-11-09 上午11 58 27

mackron commented 1 year ago

OK, I see the problem now. Thanks for pointing that out. I've pushed a potential fix to the dev branch. Are you able to give that a try?

digitalgust commented 1 year ago

The dev branch is work .

mackron commented 1 year ago

Thanks for testing that. I've released version 0.11.20 with this fix. Thanks for the report!