From 7dd38fa23a4ef815186be36caeb0522e7da7b145 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Sun, 30 Nov 2025 18:38:37 -0800 Subject: [PATCH] Fix platform ifdefs for locale independent str functions (#8678) Android libraries include which defines the __ANDROID_API__ symbol even when targeting non-Android platforms and not using Android's libc. This updates the FLATBUFFERS_LOCALE_INDEPENDENT ifdef to check for __ANDROID__ before checking the Android API level. Removes an extra check from the __Fuchsia__ branch. Fuchsia's libc does not support locales or the locale independent entry points. Updates the Android API check to check for an API level >= 26 instead of 21. This matches the Android header file's availability macros and Bionic documentation: https://android.googlesource.com/platform/bionic/+/HEAD/docs/status.md --- include/flatbuffers/base.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index 987dcbc40..368a7c9c6 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -267,11 +267,11 @@ namespace flatbuffers { #ifndef FLATBUFFERS_LOCALE_INDEPENDENT // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, - // strtoull_l}. + // strtoull_l} on platforms that support them. #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \ - (defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \ + (defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__>= 26) || \ (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \ - (!defined(__Fuchsia__) && !defined(__ANDROID_API__)) + !defined(__Fuchsia__) #define FLATBUFFERS_LOCALE_INDEPENDENT 1 #else #define FLATBUFFERS_LOCALE_INDEPENDENT 0