STK library on Android - ant compile errors


#1

I've added the STK module from dRowAudio (also tried Danlin's updated version), and although it works great via XCode, I tried compiling for Android with ```ant release``` and I am getting a ton of compile errors to do with some macros e.g. 

​

    [exec] /Users/adamelemental/dev/SDKs/android-ndk/platforms/android-9/arch-arm/usr/include/sys/endian.h:56:24: error: expected unqualified-id before '__extension__'

     [exec]  #define __swap16gen(x) __statement({     \

     [exec]                         ^

     [exec] /Users/adamelemental/dev/SDKs/android-ndk/platforms/android-9/arch-arm/usr/include/sys/endian.h:141:18: note: in expansion of macro '__swap16gen'

     [exec]  #define __swap16 __swap16gen

     [exec]                   ^

     [exec] /Users/adamelemental/dev/SDKs/android-ndk/platforms/android-9/arch-arm/usr/include/sys/endian.h:158:16: note: in expansion of macro '__swap16'

     [exec]  #define swap16 __swap16

     [exec]                 ^

     [exec] ../../JuceLibraryCode/modules/stk/../../../../../juce_modules/drowaudio/stk_module/stk/stk.h:181:15: note: in expansion of macro 'swap16'

 


#2

I look at this on this weekend


#3


I think I had the same problem a while ago.  What worked for me was to undefine a few macros temporarily in the JUCE module's stk.h header file. 


#if JUCE_ANDROID

#include <sys/endian.h>
// Stk.h defines stk::swap16/32/64.  This conflicts with macros in <sys/endian.h> on Android. Workaround: undefine them in the stk.h juce module header
#pragma message ("undefining swap16/32/64 macros to avoid conflict with stk header")
#undef swap16
#undef swap32
#undef swap64

#endif

#include "stk/ADSR.h"
#include "stk/Asymp.h"

etc...


#4

yes i found the same solution today

i add a fix on my stk_modules ASAP


#5

Great thanks all will try that tonight :)


#6

Thanks for the suggestings, but I can't seem to stop the ant compiler complaining about the swapXX definitions. I've tried the undefs in both stk.h and stk.cpp. 

 

 


#7

Found that I needed to add the #undef's to the stk_module/stk/Stk.h file - anywhere else was uneffective.