32 #ifndef CPL_BASE_H_INCLUDED
33 #define CPL_BASE_H_INCLUDED
45 #if defined(_WIN32) && !defined(WIN32)
49 #if defined(_WINDOWS) && !defined(WIN32)
58 # ifndef _CRT_SECURE_NO_DEPRECATE
59 # define _CRT_SECURE_NO_DEPRECATE
61 # ifndef _CRT_NONSTDC_NO_DEPRECATE
62 # define _CRT_NONSTDC_NO_DEPRECATE
66 #include "cpl_config.h"
73 #if !defined(SIZEOF_INT) || SIZEOF_INT != 4
74 #error "Unexpected value for SIZEOF_INT"
77 #if !defined(SIZEOF_UNSIGNED_LONG) || (SIZEOF_UNSIGNED_LONG != 4 && SIZEOF_UNSIGNED_LONG != 8)
78 #error "Unexpected value for SIZEOF_UNSIGNED_LONG"
81 #if !defined(SIZEOF_VOIDP) || (SIZEOF_VOIDP != 4 && SIZEOF_VOIDP != 8)
82 #error "Unexpected value for SIZEOF_VOIDP"
95 #if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE)
96 # define _LARGEFILE64_SOURCE 1
105 #if defined(HAVE_ICONV)
106 # define CPL_RECODE_ICONV
109 #define CPL_RECODE_STUB
118 #if defined(__MINGW32__)
119 #ifndef __MSVCRT_VERSION__
120 #define __MSVCRT_VERSION__ 0x0601
138 #if defined(HAVE_ERRNO_H)
151 # include <strings.h>
154 #if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG)
156 # include <dbmalloc.h>
159 #if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H)
161 # include <dmalloc.h>
174 # if __cplusplus >= 201103L
175 # define HAVE_CXX11 1
183 #if UINT_MAX == 65535
185 typedef unsigned long GUInt32;
188 typedef unsigned int GUInt32;
191 typedef short GInt16;
192 typedef unsigned short GUInt16;
193 typedef unsigned char GByte;
196 #ifndef CPL_GBOOL_DEFINED
197 #define CPL_GBOOL_DEFINED
205 #if defined(WIN32) && defined(_MSC_VER)
207 #define VSI_LARGE_API_SUPPORTED
208 typedef __int64 GIntBig;
209 typedef unsigned __int64 GUIntBig;
211 #define GINTBIG_MIN ((GIntBig)(0x80000000) << 32)
212 #define GINTBIG_MAX (((GIntBig)(0x7FFFFFFF) << 32) | 0xFFFFFFFFU)
213 #define GUINTBIG_MAX (((GUIntBig)(0xFFFFFFFFU) << 32) | 0xFFFFFFFFU)
217 typedef long long GIntBig;
218 typedef unsigned long long GUIntBig;
220 #define GINTBIG_MIN ((GIntBig)(0x80000000) << 32)
221 #define GINTBIG_MAX (((GIntBig)(0x7FFFFFFF) << 32) | 0xFFFFFFFFU)
222 #define GUINTBIG_MAX (((GUIntBig)(0xFFFFFFFFU) << 32) | 0xFFFFFFFFU)
226 typedef long GIntBig;
227 typedef unsigned long GUIntBig;
229 #define GINTBIG_MIN INT_MIN
230 #define GINTBIG_MAX INT_MAX
231 #define GUINTBIG_MAX UINT_MAX
234 #if SIZEOF_VOIDP == 8
235 typedef GIntBig GPtrDiff_t;
237 typedef int GPtrDiff_t;
240 #if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER))
241 #define CPL_FRMT_GB_WITHOUT_PREFIX "I64"
243 #define CPL_FRMT_GB_WITHOUT_PREFIX "ll"
245 #define CPL_FRMT_GB_WITHOUT_PREFIX "l"
248 #define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d"
249 #define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u"
252 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
253 #define GUINTBIG_TO_DOUBLE(x) (double)(GIntBig)(x)
255 #define GUINTBIG_TO_DOUBLE(x) (double)(x)
258 #ifdef COMPAT_WITH_ICC_CONVERSION_CHECK
259 #define CPL_INT64_FITS_ON_INT32(x) ((x) >= INT_MIN && (x) <= INT_MAX)
261 #define CPL_INT64_FITS_ON_INT32(x) (((GIntBig)(int)(x)) == (x))
268 # define CPL_C_START extern "C" {
276 #if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
277 # define CPL_DLL __declspec(dllexport)
279 # if defined(USE_GCC_VISIBILITY_FLAG)
280 # define CPL_DLL __attribute__ ((visibility("default")))
288 #ifdef CPL_OPTIONAL_APIS
289 # define CPL_ODLL CPL_DLL
295 #if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL)
296 # define CPL_STDCALL __stdcall
303 # define FORCE_CDECL __cdecl
309 #if (defined(__GNUC__) && !defined(__NO_INLINE__)) || defined(_MSC_VER)
310 #define HAS_CPL_INLINE 1
311 #define CPL_INLINE __inline
312 #elif defined(__SUNPRO_CC)
313 #define HAS_CPL_INLINE 1
314 #define CPL_INLINE inline
321 #if defined(NULL_AS_NULLPTR) && HAVE_CXX11
329 #include <sys/types.h>
334 #include <sys/mman.h>
365 # define MIN(a,b) ((a<b) ? a : b)
366 # define MAX(a,b) ((a>b) ? a : b)
370 # define ABS(x) ((x<0) ? (-1*(x)) : x)
374 # define M_PI 3.14159265358979323846
384 # define CPLIsEqual(x,y) (fabs((x) - (y)) < 0.0000000000001)
392 #if defined(AFL_FRIENDLY) && defined(__GNUC__)
394 static inline int CPL_afl_friendly_memcmp(
const void* ptr1,
const void* ptr2,
size_t len)
395 __attribute__((always_inline));
397 static inline int CPL_afl_friendly_memcmp(
const void* ptr1,
const void* ptr2,
size_t len)
399 const unsigned char* bptr1 = (
const unsigned char*)ptr1;
400 const unsigned char* bptr2 = (
const unsigned char*)ptr2;
403 unsigned char b1 = *(bptr1++);
404 unsigned char b2 = *(bptr2++);
405 if( b1 != b2 )
return b1 - b2;
410 static inline int CPL_afl_friendly_strcmp(
const char* ptr1,
const char* ptr2)
411 __attribute__((always_inline));
413 static inline int CPL_afl_friendly_strcmp(
const char* ptr1,
const char* ptr2)
415 const unsigned char* usptr1 = (
const unsigned char*)ptr1;
416 const unsigned char* usptr2 = (
const unsigned char*)ptr2;
419 unsigned char ch1 = *(usptr1++);
420 unsigned char ch2 = *(usptr2++);
421 if( ch1 == 0 || ch1 != ch2 )
return ch1 - ch2;
425 static inline int CPL_afl_friendly_strncmp(
const char* ptr1,
const char* ptr2,
size_t len)
426 __attribute__((always_inline));
428 static inline int CPL_afl_friendly_strncmp(
const char* ptr1,
const char* ptr2,
size_t len)
430 const unsigned char* usptr1 = (
const unsigned char*)ptr1;
431 const unsigned char* usptr2 = (
const unsigned char*)ptr2;
434 unsigned char ch1 = *(usptr1++);
435 unsigned char ch2 = *(usptr2++);
436 if( ch1 == 0 || ch1 != ch2 )
return ch1 - ch2;
441 static inline int CPL_afl_friendly_strcasecmp(
const char* ptr1,
const char* ptr2)
442 __attribute__((always_inline));
444 static inline int CPL_afl_friendly_strcasecmp(
const char* ptr1,
const char* ptr2)
446 const unsigned char* usptr1 = (
const unsigned char*)ptr1;
447 const unsigned char* usptr2 = (
const unsigned char*)ptr2;
450 unsigned char ch1 = *(usptr1++);
451 unsigned char ch2 = *(usptr2++);
452 ch1 = (
unsigned char)toupper(ch1);
453 ch2 = (
unsigned char)toupper(ch2);
454 if( ch1 == 0 || ch1 != ch2 )
return ch1 - ch2;
458 static inline int CPL_afl_friendly_strncasecmp(
const char* ptr1,
const char* ptr2,
size_t len)
459 __attribute__((always_inline));
461 static inline int CPL_afl_friendly_strncasecmp(
const char* ptr1,
const char* ptr2,
size_t len)
463 const unsigned char* usptr1 = (
const unsigned char*)ptr1;
464 const unsigned char* usptr2 = (
const unsigned char*)ptr2;
467 unsigned char ch1 = *(usptr1++);
468 unsigned char ch2 = *(usptr2++);
469 ch1 = (
unsigned char)toupper(ch1);
470 ch2 = (
unsigned char)toupper(ch2);
471 if( ch1 == 0 || ch1 != ch2 )
return ch1 - ch2;
476 static inline char* CPL_afl_friendly_strstr(
const char* haystack,
const char* needle)
477 __attribute__((always_inline));
479 static inline char* CPL_afl_friendly_strstr(
const char* haystack,
const char* needle)
481 const char* ptr_haystack = haystack;
484 const char* ptr_haystack2 = ptr_haystack;
485 const char* ptr_needle = needle;
488 char ch1 = *(ptr_haystack2++);
489 char ch2 = *(ptr_needle++);
491 return (
char*)ptr_haystack;
495 if( *ptr_haystack == 0 )
503 #define memcmp CPL_afl_friendly_memcmp
504 #define strcmp CPL_afl_friendly_strcmp
505 #define strncmp CPL_afl_friendly_strncmp
506 #define strcasecmp CPL_afl_friendly_strcasecmp
507 #define strncasecmp CPL_afl_friendly_strncasecmp
508 #define strstr CPL_afl_friendly_strstr
513 # define STRCASECMP(a,b) (stricmp(a,b))
514 # define STRNCASECMP(a,b,n) (strnicmp(a,b,n))
516 # define STRCASECMP(a,b) (strcasecmp(a,b))
517 # define STRNCASECMP(a,b,n) (strncasecmp(a,b,n))
519 # define EQUALN(a,b,n) (STRNCASECMP(a,b,n)==0)
520 # define EQUAL(a,b) (STRCASECMP(a,b)==0)
527 #ifndef STARTS_WITH_CI
528 #define STARTS_WITH(a,b) (strncmp(a,b,strlen(b)) == 0)
529 #define STARTS_WITH_CI(a,b) EQUALN(a,b,strlen(b))
532 #ifndef CPL_THREADLOCAL
533 # define CPL_THREADLOCAL
547 # define CPLIsNan(x) _isnan(x)
548 # define CPLIsInf(x) (!_isnan(x) && !_finite(x))
549 # define CPLIsFinite(x) _finite(x)
550 #elif defined(HAVE_CXX11) && HAVE_CXX11 && defined(__GNUC__)
553 # define CPLIsNan(x) __builtin_isnan(x)
554 # define CPLIsInf(x) __builtin_isinf(x)
555 # define CPLIsFinite(x) __builtin_isfinite(x)
557 # define CPLIsNan(x) isnan(x)
559 # define CPLIsInf(x) isinf(x)
560 # define CPLIsFinite(x) (!isnan(x) && !isinf(x))
561 # elif defined(__sun__)
563 # define CPLIsInf(x) (!finite(x) && !isnan(x))
564 # define CPLIsFinite(x) finite(x)
566 # define CPLIsInf(x) (0)
567 # define CPLIsFinite(x) (!isnan(x))
578 #if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB)
582 #if ! ( defined(CPL_LSB) || defined(CPL_MSB) )
587 # define CPL_IS_LSB 1
589 # define CPL_IS_LSB 0
599 static void my_function() {}
604 #define CPL_STATIC_ASSERT(x) CPLStaticAssert<x>::my_function()
605 #define CPL_STATIC_ASSERT_IF_AVAILABLE(x) CPL_STATIC_ASSERT(x)
609 #define CPL_STATIC_ASSERT_IF_AVAILABLE(x)
617 #define CPL_SWAP16(x) \
619 (((GUInt16)(x) & 0x00ffU) << 8) | \
620 (((GUInt16)(x) & 0xff00U) >> 8) ))
622 #define CPL_SWAP16PTR(x) \
624 GByte byTemp, *_pabyDataT = (GByte *) (x); \
625 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2); \
627 byTemp = _pabyDataT[0]; \
628 _pabyDataT[0] = _pabyDataT[1]; \
629 _pabyDataT[1] = byTemp; \
632 #define CPL_SWAP32(x) \
634 (((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \
635 (((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \
636 (((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \
637 (((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) ))
639 #define CPL_SWAP32PTR(x) \
641 GByte byTemp, *_pabyDataT = (GByte *) (x); \
642 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \
644 byTemp = _pabyDataT[0]; \
645 _pabyDataT[0] = _pabyDataT[3]; \
646 _pabyDataT[3] = byTemp; \
647 byTemp = _pabyDataT[1]; \
648 _pabyDataT[1] = _pabyDataT[2]; \
649 _pabyDataT[2] = byTemp; \
652 #define CPL_SWAP64PTR(x) \
654 GByte byTemp, *_pabyDataT = (GByte *) (x); \
655 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \
657 byTemp = _pabyDataT[0]; \
658 _pabyDataT[0] = _pabyDataT[7]; \
659 _pabyDataT[7] = byTemp; \
660 byTemp = _pabyDataT[1]; \
661 _pabyDataT[1] = _pabyDataT[6]; \
662 _pabyDataT[6] = byTemp; \
663 byTemp = _pabyDataT[2]; \
664 _pabyDataT[2] = _pabyDataT[5]; \
665 _pabyDataT[5] = byTemp; \
666 byTemp = _pabyDataT[3]; \
667 _pabyDataT[3] = _pabyDataT[4]; \
668 _pabyDataT[4] = byTemp; \
688 #define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
691 # define CPL_MSBWORD16(x) (x)
692 # define CPL_LSBWORD16(x) CPL_SWAP16(x)
693 # define CPL_MSBWORD32(x) (x)
694 # define CPL_LSBWORD32(x) CPL_SWAP32(x)
695 # define CPL_MSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
696 # define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
697 # define CPL_MSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
698 # define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
699 # define CPL_MSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
700 # define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
702 # define CPL_LSBWORD16(x) (x)
703 # define CPL_MSBWORD16(x) CPL_SWAP16(x)
704 # define CPL_LSBWORD32(x) (x)
705 # define CPL_MSBWORD32(x) CPL_SWAP32(x)
706 # define CPL_LSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
707 # define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
708 # define CPL_LSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
709 # define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
710 # define CPL_LSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
711 # define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
715 #define CPL_LSBINT16PTR(x) ((*(GByte*)(x)) | (*(((GByte*)(x))+1) << 8))
718 #define CPL_LSBINT32PTR(x) ((*(GByte*)(x)) | (*(((GByte*)(x))+1) << 8) | \
719 (*(((GByte*)(x))+2) << 16) | (*(((GByte*)(x))+3) << 24))
722 #define CPL_LSBSINT16PTR(x) ((GInt16) CPL_LSBINT16PTR(x))
725 #define CPL_LSBUINT16PTR(x) ((GUInt16)CPL_LSBINT16PTR(x))
728 #define CPL_LSBSINT32PTR(x) ((GInt32) CPL_LSBINT32PTR(x))
731 #define CPL_LSBUINT32PTR(x) ((GUInt32)CPL_LSBINT32PTR(x))
735 #ifndef UNREFERENCED_PARAM
736 # ifdef UNREFERENCED_PARAMETER
737 # define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param)
739 # define UNREFERENCED_PARAM(param) ((void)param)
751 #ifndef DISABLE_CVSID
752 #if defined(__GNUC__) && __GNUC__ >= 4
753 # define CPL_CVSID(string) static const char cpl_cvsid[] __attribute__((used)) = string;
755 # define CPL_CVSID(string) static const char cpl_cvsid[] = string; \
756 static const char *cvsid_aw() { return( cvsid_aw() ? NULL : cpl_cvsid ); }
759 # define CPL_CVSID(string)
764 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) && !(defined(__MINGW64__) && __GNUC__ == 4 && __GNUC_MINOR__ == 6)
765 # define CPL_NULL_TERMINATED __attribute__((__sentinel__))
767 # define CPL_NULL_TERMINATED
770 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
771 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
772 #define CPL_SCAN_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
774 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx )
775 #define CPL_SCAN_FUNC_FORMAT( format_idx, arg_idx )
778 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
779 #define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
781 #define CPL_WARN_UNUSED_RESULT
784 #if defined(__GNUC__) && __GNUC__ >= 4
785 # define CPL_UNUSED __attribute((__unused__))
791 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
792 #define CPL_NO_RETURN __attribute__((noreturn))
794 #define CPL_NO_RETURN
798 #ifndef __has_attribute
799 #define __has_attribute(x) 0 // Compatibility with non-clang compilers.
802 #if ((defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) || __has_attribute(returns_nonnull)) && !defined(DOXYGEN_SKIP)
803 # define CPL_RETURNS_NONNULL __attribute__((returns_nonnull))
805 # define CPL_RETURNS_NONNULL
809 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
810 #define CPL_RESTRICT __restrict__
823 # define CPL_FINAL final
824 # define CPL_DISALLOW_COPY_ASSIGN(ClassName) \
825 ClassName( const ClassName & ) = delete; \
826 ClassName &operator=( const ClassName & ) = delete;
829 # define CPL_DISALLOW_COPY_ASSIGN(ClassName) \
830 ClassName( const ClassName & ); \
831 ClassName &operator=( const ClassName & );
836 #if !defined(DOXYGEN_SKIP)
837 #if defined(__has_extension)
838 #if __has_extension(attribute_deprecated_with_message)
840 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated(x)))
842 #define CPL_WARN_DEPRECATED(x)
844 #elif defined(__GNUC__)
845 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated))
847 #define CPL_WARN_DEPRECATED(x)
851 #if !defined(_MSC_VER) && !defined(__APPLE__)
853 #ifdef WARN_STANDARD_PRINTF
854 int vsnprintf(
char *str,
size_t size,
const char* fmt, va_list args) CPL_WARN_DEPRECATED(
"Use CPLvsnprintf() instead");
855 int snprintf(
char *str,
size_t size,
const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(3,4) CPL_WARN_DEPRECATED("Use
CPLsnprintf() instead");
856 int sprintf(
char *str, const
char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use
CPLsnprintf() instead");
857 #elif defined(GDAL_COMPILATION) && !defined(DONT_DEPRECATE_SPRINTF)
858 int sprintf(
char *str,
const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or
CPLsnprintf() instead");
863 #if defined(MAKE_SANITIZE_HAPPY) || !(defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64))
864 #define CPL_CPU_REQUIRES_ALIGNED_ACCESS
865 #define CPL_IS_DOUBLE_A_INT(d) ( (d) >= INT_MIN && (d) <= INT_MAX && (double)(int)(d) == (d) )
868 #define CPL_IS_DOUBLE_A_INT(d) ( (double)(int)(d) == (d) )
873 #define CPL_ARRAYSIZE(array) \
874 ((sizeof(array) / sizeof(*(array))) / \
875 static_cast<size_t>(!(sizeof(array) % sizeof(*(array)))))
878 template<
class T>
static void CPL_IGNORE_RET_VAL(T) {}
879 inline static bool CPL_TO_BOOL(
int x) {
return x != 0; }
884 #if (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || (defined(__clang__) && __clang_major__ >= 3)) && !defined(_MSC_VER))
885 #define HAVE_GCC_DIAGNOSTIC_PUSH
888 #if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) && !defined(_MSC_VER))
889 #define HAVE_GCC_SYSTEM_HEADER
892 #if defined(__clang__)
893 # define CPL_FALLTHROUGH [[clang::fallthrough]];
895 # define CPL_FALLTHROUGH
902 #if defined(__cplusplus) && defined(DEBUG_BOOL) && !defined(DO_NOT_USE_DEBUG_BOOL)
904 class MSVCPedanticBool
907 friend bool operator== (
const bool& one,
const MSVCPedanticBool& other);
908 friend bool operator!= (
const bool& one,
const MSVCPedanticBool& other);
911 MSVCPedanticBool(
int bIn);
916 MSVCPedanticBool() {}
917 MSVCPedanticBool(
bool bIn) : b(bIn) {}
918 MSVCPedanticBool(
const MSVCPedanticBool& other) : b(other.b) {}
920 MSVCPedanticBool& operator= (
const MSVCPedanticBool& other) { b = other.b;
return *
this; }
921 MSVCPedanticBool& operator&= (
const MSVCPedanticBool& other) { b &= other.b;
return *
this; }
922 MSVCPedanticBool& operator|= (
const MSVCPedanticBool& other) { b |= other.b;
return *
this; }
924 bool operator== (
const bool& other)
const {
return b == other; }
925 bool operator!= (
const bool& other)
const {
return b != other; }
926 bool operator== (
const MSVCPedanticBool& other)
const {
return b == other.b; }
927 bool operator!= (
const MSVCPedanticBool& other)
const {
return b != other.b; }
929 bool operator! ()
const {
return !b; }
930 operator bool()
const {
return b; }
931 operator int()
const {
return b; }
934 inline bool operator== (
const bool& one,
const MSVCPedanticBool& other) {
return one == other.b; }
935 inline bool operator!= (
const bool& one,
const MSVCPedanticBool& other) {
return one != other.b; }
956 #define EMULATED_BOOL int
959 #define bool MSVCPedanticBool
963 #define VOLATILE_BOOL bool
975 #define EMULATED_BOOL bool
976 #define VOLATILE_BOOL volatile bool
Definition: cpl_port.h:596
int CPLsnprintf(char *str, size_t size, const char *fmt,...)
snprintf() wrapper that is not sensitive to LC_NUMERIC settings.
Definition: cpl_string.cpp:1305