#include <iterator>
#include <memory>
+#if defined(__unix__) && !defined(FLATBUFFERS_LOCALE_INDEPENDENT)
+#include <unistd.h>
+#endif
+
#ifdef _STLPORT_VERSION
#define FLATBUFFERS_CPP98_STL
#endif
#include <functional>
#endif
+#ifdef __ANDROID__
+ #include <android/api-level.h>
+#endif
+
#include "flatbuffers/stl_emulation.h"
#if defined(__ICCARM__)
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l, strtoull_l}.
- // They are part of the POSIX-2008 but not part of the C/C++ standard.
- // GCC/Clang have definition (_XOPEN_SOURCE>=700) if POSIX-2008.
#if ((defined(_MSC_VER) && _MSC_VER >= 1800) || \
- (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE>=700)))
+ (defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21))))
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
#else
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
// clang-format off
// Dont't remove `format off`, it prevent reordering of win-includes.
-#define _POSIX_C_SOURCE 200112L // For stat from stat/stat.h and fseeko() (POSIX extensions).
+
+# define _POSIX_C_SOURCE 200809L
+# define _XOPEN_SOURCE 700L
+
#ifdef _WIN32
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# include <direct.h>
# include <winbase.h>
# undef interface // This is also important because of reasons
-#else
-# define _XOPEN_SOURCE 600 // For PATH_MAX from limits.h (SUSv2 extension)
-# include <limits.h>
#endif
// clang-format on
#include <sys/stat.h>
#include <clocale>
+#include <cstdlib>
#include <fstream>
namespace flatbuffers {
char abs_path[MAX_PATH];
return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr)
#else
- char abs_path[PATH_MAX];
- return realpath(filepath.c_str(), abs_path)
+ char *abs_path_temp = realpath(filepath.c_str(), nullptr);
+ bool success = abs_path_temp != nullptr;
+ std::string abs_path;
+ if(success) {
+ abs_path = abs_path_temp;
+ free(abs_path_temp);
+ }
+ return success
#endif
? abs_path
: filepath;