MIN/MAX Macros in stdio.h cause duplicate definitions
For context: I'm giving the CrystaX NDK a try on our cross-platform C++ code at Dropbox, previously built with NDK r11c, GCC 4.9, with GNU STL. I'm not sure if all of the issues I ran into will be considered bugs, but since your stated goal is to be a drop-in replacement I thought it worth sharing them as differences which an adopter has to deal with. We run with -Werror so any warnings will block our build.
The CrystaX headers define macros
MIN() and MAX() in
stdio.h. This isn't standard on Android (I haven't heard of it being standard anywhere other than Windows), and ends up causing duplicate definitions in some 3rd-party code which defines its own such macros, including sqlite3 and kiss_fft. Full error details below. I've been able to work around this by modifying the 3rd-party sources to rename their macros, but I'd prefer not to have to maintain patches to that code.
[armeabi-v7a] Compile thumb : dbx_sqlite3 <= dbx_sqlite3.c jni/../../../../dbx/external/dbx_sqlite3/cpp/impl/dbx_sqlite3.c:8816:0: error: "MIN" redefined [-Werror] #define MIN(A,B) ((A)<(B)?(A):(B)) ^ In file included from /Users/atwyman/Library/Android/ndk/platforms/android-16/arch-arm/usr/include/stdio.h:43:0, from jni/../../../../dbx/external/dbx_sqlite3/cpp/impl/dbx_sqlite3.c:8719: /Users/atwyman/Library/Android/ndk/sources/crystax/include/crystax/freebsd.h:138:0: note: this is the location of the previous definition #define MIN(a,b) (((a)<(b))?(a):(b)) ^ jni/../../../../dbx/external/dbx_sqlite3/cpp/impl/dbx_sqlite3.c:8817:0: error: "MAX" redefined [-Werror] #define MAX(A,B) ((A)>(B)?(A):(B)) ^ In file included from /Users/atwyman/Library/Android/ndk/platforms/android-16/arch-arm/usr/include/stdio.h:43:0, from jni/../../../../dbx/external/dbx_sqlite3/cpp/impl/dbx_sqlite3.c:8719: /Users/atwyman/Library/Android/ndk/sources/crystax/include/crystax/freebsd.h:142:0: note: this is the location of the previous definition #define MAX(a,b) (((a)>(b))?(a):(b)) ^ cc1: all warnings being treated as errors
Updated by Andrew Twyman over 2 years ago
As an aside/addendum, I ran into some other duplicate macros like
F_LOCK, but in that case it seems that the macros are part of CrystaX adding a missing feature. The conflict there was only with a source file which was intended to pave over the missing features of Android (Chromium's
os_compat_android.h) so in that it's definitely not something CrystaX should change, but instead something I need to disable in the adaptation code.