Standard_CLocaleSentry does not include xlocale.h when using glibc anymore.
HAVE_XLOCALE_H has been renamed to OCCT_CLOCALE_POSIX2008 to avoid confusion.
Renamed macros OCC_CHECK_BASE_CLASS -> OCCT_CHECK_BASE_CLASS.
public:
CLocalePtr()
- #ifdef HAVE_XLOCALE_H
+ #ifdef OCCT_CLOCALE_POSIX2008
: myLocale (newlocale (LC_ALL_MASK, "C", NULL))
#elif defined(_MSC_VER)
: myLocale (_create_locale (LC_ALL, "C"))
~CLocalePtr()
{
- #ifdef HAVE_XLOCALE_H
+ #ifdef OCCT_CLOCALE_POSIX2008
freelocale (myLocale);
#elif defined(_MSC_VER)
_free_locale (myLocale);
// purpose :
// =======================================================================
Standard_CLocaleSentry::Standard_CLocaleSentry()
-#ifdef HAVE_XLOCALE_H
+#ifdef OCCT_CLOCALE_POSIX2008
: myPrevLocale (uselocale (theCLocale.myLocale)) // switch to C locale within this thread only using xlocale API
#else
: myPrevLocale (setlocale (LC_ALL, 0))
#endif
#endif
{
-#if !defined(HAVE_XLOCALE_H)
+#if !defined(OCCT_CLOCALE_POSIX2008)
const char* aPrevLocale = (const char* )myPrevLocale;
if (myPrevLocale == NULL
|| (aPrevLocale[0] == 'C' && aPrevLocale[1] == '\0'))
// =======================================================================
Standard_CLocaleSentry::~Standard_CLocaleSentry()
{
-#if defined(HAVE_XLOCALE_H)
+#if defined(OCCT_CLOCALE_POSIX2008)
uselocale ((locale_t )myPrevLocale);
#else
if (myPrevLocale != NULL)
#include <locale.h>
-#ifndef HAVE_XLOCALE_H
- //! "xlocale.h" available in Mac OS X and glibc (Linux) for a long time as an extension
- //! and become part of POSIX since '2008.
- //! Notice that this is impossible to test (_POSIX_C_SOURCE >= 200809L)
- //! since POSIX didn't declared such identifier.
+#if defined(__APPLE__)
+ #include <xlocale.h>
+#endif
+
+#ifndef OCCT_CLOCALE_POSIX2008
+ //! @def OCCT_CLOCALE_POSIX2008
+ //!
+ //! POSIX.1-2008 extends C locale API by providing methods like newlocale/freelocale/uselocale.
+ //! Presence of this extension cannot be checked in straightforward way (like (_POSIX_C_SOURCE >= 200809L))
+ //! due to missing such declarations in standard.
+ //! On macOS new functions are declared within "xlocale.h" header (the same is for glibc, but this header has been removed since glibc 2.26).
#if defined(__APPLE__)
- #define HAVE_XLOCALE_H
+ #define OCCT_CLOCALE_POSIX2008
#endif
//! We check _GNU_SOURCE for glibc extensions here and it is always defined by g++ compiler.
#if defined(_GNU_SOURCE) && !defined(__ANDROID__)
- #define HAVE_XLOCALE_H
+ #define OCCT_CLOCALE_POSIX2008
#endif
-#endif // ifndef HAVE_LOCALE_H
-
-#if defined(HAVE_XLOCALE_H) && !(defined(__GLIBC__) && (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 24))
- // xlocale.h is actually a non-standard header file; glibc 2.26 has removed it altogether (all definition comes from locale.h)
- #include <xlocale.h>
#endif
#if !defined(__ANDROID__)
public:
-#ifdef HAVE_XLOCALE_H
+#ifdef OCCT_CLOCALE_POSIX2008
typedef locale_t clocale_t;
#elif defined(_MSC_VER)
typedef _locale_t clocale_t;
// and newlocale/uselocale/freelocale to switch locale within current thread only.
// So we switch to C locale temporarily
#define SAVE_TL() Standard_CLocaleSentry aLocaleSentry;
- #ifndef HAVE_XLOCALE_H
+ #ifndef OCCT_CLOCALE_POSIX2008
// glibc version for android platform use locale-independent implementation of
// strtod, strtol, strtoll functions. For other system with locale-depended
// implementations problems may appear if "C" locale is not set explicitly.
// DEFINE_STANDARD_RTTI* macro is actually a base class.
// For GCC 4.7+, more strict check is possible -- ensuring that base class
// is direct base -- using non-standard C++ reflection functionality.
-#if ! defined(OCC_CHECK_BASE_CLASS)
+#if ! defined(OCCT_CHECK_BASE_CLASS)
#if (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ > 4)))
#include <tr2/type_traits>
struct has_type<T, std::tuple<T, Ts...> > : std::true_type {};
}
-#define OCC_CHECK_BASE_CLASS(Class,Base) \
+#define OCCT_CHECK_BASE_CLASS(Class,Base) \
using direct_base_classes = opencascade::direct_base_class_as_tuple<std::tr2::direct_bases<Class>::type>::type; \
static_assert(opencascade::has_type<Base, direct_base_classes>::type::value, "OCCT RTTI definition is incorrect: " #Base " is not direct base class of " #Class);
#else /* ! GCC 4.7+ */
-#define OCC_CHECK_BASE_CLASS(Class,Base) \
+#define OCCT_CHECK_BASE_CLASS(Class,Base) \
static_assert(opencascade::is_base_but_not_same<Base, Class>::value, "OCCT RTTI definition is incorrect: " #Base " is not base class of " #Class);
#endif /* GCC 4.7+ */
-#endif /* ! defined(OCC_CHECK_BASE_CLASS) */
+#endif /* ! defined(OCCT_CHECK_BASE_CLASS) */
//! Helper macro to get instance of a type descriptor for a class in a legacy way.
#define STANDARD_TYPE(theType) theType::get_type_descriptor()
#define DEFINE_STANDARD_RTTI_INLINE(Class,Base) \
public: \
typedef Base base_type; \
- static const char* get_type_name () { return #Class; OCC_CHECK_BASE_CLASS(Class,Base) } \
+ static const char* get_type_name () { return #Class; OCCT_CHECK_BASE_CLASS(Class,Base) } \
static const Handle(Standard_Type)& get_type_descriptor () { return Standard_Type::Instance<Class>(); } \
virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE { \
static_assert(std::is_same<const Class*, decltype(this)>::value, "OCCT RTTI definition is misplaced: current class is not " #Class); \
#define DEFINE_STANDARD_RTTIEXT(Class,Base) \
public: \
typedef Base base_type; \
- static const char* get_type_name () { return #Class; OCC_CHECK_BASE_CLASS(Class,Base) } \
+ static const char* get_type_name () { return #Class; OCCT_CHECK_BASE_CLASS(Class,Base) } \
Standard_EXPORT static const Handle(Standard_Type)& get_type_descriptor (); \
Standard_EXPORT virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE;