Skip to content

Commit 7dd38fa

Browse files
authored
Fix platform ifdefs for locale independent str functions (#8678)
Android libraries include <android/api-level.h> 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
1 parent 7350c36 commit 7dd38fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/flatbuffers/base.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ namespace flatbuffers {
267267

268268
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
269269
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
270-
// strtoull_l}.
270+
// strtoull_l} on platforms that support them.
271271
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
272-
(defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
272+
(defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__>= 26) || \
273273
(defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
274-
(!defined(__Fuchsia__) && !defined(__ANDROID_API__))
274+
!defined(__Fuchsia__)
275275
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
276276
#else
277277
#define FLATBUFFERS_LOCALE_INDEPENDENT 0

0 commit comments

Comments
 (0)