16#ifndef CPL_BASE_H_INCLUDED
17#define CPL_BASE_H_INCLUDED
31#ifndef _CRT_SECURE_NO_DEPRECATE
32#define _CRT_SECURE_NO_DEPRECATE
34#ifndef _CRT_NONSTDC_NO_DEPRECATE
35#define _CRT_NONSTDC_NO_DEPRECATE
39#include "cpl_config.h"
46#if !defined(SIZEOF_INT) || SIZEOF_INT != 4
47#error "Unexpected value for SIZEOF_INT"
50#if !defined(SIZEOF_UNSIGNED_LONG) || \
51 (SIZEOF_UNSIGNED_LONG != 4 && SIZEOF_UNSIGNED_LONG != 8)
52#error "Unexpected value for SIZEOF_UNSIGNED_LONG"
55#if !defined(SIZEOF_VOIDP)
56#error "Unexpected value for SIZEOF_VOIDP"
69#if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE)
70#define _LARGEFILE64_SOURCE 1
79#if defined(HAVE_ICONV)
80#define CPL_RECODE_ICONV
83#define CPL_RECODE_STUB
91#if defined(GDAL_COMPILATION) && defined(__sun__) && \
92 (__STDC_VERSION__ + 0) >= 201112L && (_XOPEN_SOURCE + 0) < 600
96#define _XOPEN_SOURCE 600
139#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
140#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900))
141#error Must have C++11 or newer.
143#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
146#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
175#ifndef CPL_GBOOL_DEFINED
177#define CPL_GBOOL_DEFINED
185#define CPL_STATIC_CAST(type, expr) static_cast<type>(expr)
186#define CPL_REINTERPRET_CAST(type, expr) reinterpret_cast<type>(expr)
188#define CPL_STATIC_CAST(type, expr) ((type)(expr))
189#define CPL_REINTERPRET_CAST(type, expr) ((type)(expr))
205#define GINTBIG_MIN (CPL_STATIC_CAST(GIntBig, 0x80000000) << 32)
207#define GINTBIG_MAX ((CPL_STATIC_CAST(GIntBig, 0x7FFFFFFF) << 32) | 0xFFFFFFFFU)
209#define GUINTBIG_MAX \
210 ((CPL_STATIC_CAST(GUIntBig, 0xFFFFFFFFU) << 32) | 0xFFFFFFFFU)
213#define CPL_HAS_GINT64 1
225#define GINT64_MIN GINTBIG_MIN
227#define GINT64_MAX GINTBIG_MAX
229#define GUINT64_MAX GUINTBIG_MAX
235#elif SIZEOF_VOIDP == 8
243#ifdef GDAL_COMPILATION
245typedef uintptr_t GUIntptr_t;
246#define CPL_IS_ALIGNED(ptr, quant) \
247 ((CPL_REINTERPRET_CAST(GUIntptr_t, CPL_STATIC_CAST(const void *, ptr)) % \
252#if (defined(__MSVCRT__) && !(defined(__MINGW64__) && __GNUC__ >= 10)) || \
253 (defined(_WIN32) && defined(_MSC_VER))
254#define CPL_FRMT_GB_WITHOUT_PREFIX "I64"
257#define CPL_FRMT_GB_WITHOUT_PREFIX "ll"
261#define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d"
263#define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u"
266#ifdef COMPAT_WITH_ICC_CONVERSION_CHECK
267#define CPL_INT64_FITS_ON_INT32(x) ((x) >= INT_MIN && (x) <= INT_MAX)
269#define CPL_INT64_FITS_ON_INT32(x) \
270 (CPL_STATIC_CAST(GIntBig, CPL_STATIC_CAST(int, x)) == (x))
290#if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
291#ifdef GDAL_COMPILATION
292#define CPL_DLL __declspec(dllexport)
298#if defined(USE_GCC_VISIBILITY_FLAG)
299#define CPL_DLL __attribute__((visibility("default")))
300#if !defined(__MINGW32__)
301#define CPL_INTERNAL __attribute__((visibility("hidden")))
312#define CPL_UNSTABLE_API CPL_DLL
318#ifdef CPL_OPTIONAL_APIS
319#define CPL_ODLL CPL_DLL
326#if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL)
327#define CPL_STDCALL __stdcall
335#define FORCE_CDECL __cdecl
343#if (defined(__GNUC__) && !defined(__NO_INLINE__)) || defined(_MSC_VER)
344#define HAS_CPL_INLINE 1
345#define CPL_INLINE __inline
346#elif defined(__SUNPRO_CC)
347#define HAS_CPL_INLINE 1
348#define CPL_INLINE inline
356#define MIN(a, b) (((a) < (b)) ? (a) : (b))
358#define MAX(a, b) (((a) > (b)) ? (a) : (b))
363#define ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
368#define M_PI 3.14159265358979323846
379#define CPLIsEqual(x, y) (fabs((x) - (y)) < 0.0000000000001)
388#if defined(AFL_FRIENDLY) && defined(__GNUC__)
390static inline int CPL_afl_friendly_memcmp(
const void *ptr1,
const void *ptr2,
392 __attribute__((always_inline));
394static inline int CPL_afl_friendly_memcmp(
const void *ptr1,
const void *ptr2,
397 const unsigned char *bptr1 = (
const unsigned char *)ptr1;
398 const unsigned char *bptr2 = (
const unsigned char *)ptr2;
401 unsigned char b1 = *(bptr1++);
402 unsigned char b2 = *(bptr2++);
409static inline int CPL_afl_friendly_strcmp(
const char *ptr1,
const char *ptr2)
410 __attribute__((always_inline));
412static inline int CPL_afl_friendly_strcmp(
const char *ptr1,
const char *ptr2)
414 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
415 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
418 unsigned char ch1 = *(usptr1++);
419 unsigned char ch2 = *(usptr2++);
420 if (ch1 == 0 || ch1 != ch2)
425static inline int CPL_afl_friendly_strncmp(
const char *ptr1,
const char *ptr2,
427 __attribute__((always_inline));
429static inline int CPL_afl_friendly_strncmp(
const char *ptr1,
const char *ptr2,
432 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
433 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
436 unsigned char ch1 = *(usptr1++);
437 unsigned char ch2 = *(usptr2++);
438 if (ch1 == 0 || ch1 != ch2)
444static inline int CPL_afl_friendly_strcasecmp(
const char *ptr1,
446 __attribute__((always_inline));
448static inline int CPL_afl_friendly_strcasecmp(
const char *ptr1,
451 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
452 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
455 unsigned char ch1 = *(usptr1++);
456 unsigned char ch2 = *(usptr2++);
457 ch1 = (
unsigned char)toupper(ch1);
458 ch2 = (
unsigned char)toupper(ch2);
459 if (ch1 == 0 || ch1 != ch2)
464static inline int CPL_afl_friendly_strncasecmp(
const char *ptr1,
465 const char *ptr2,
size_t len)
466 __attribute__((always_inline));
468static inline int CPL_afl_friendly_strncasecmp(
const char *ptr1,
469 const char *ptr2,
size_t len)
471 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
472 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
475 unsigned char ch1 = *(usptr1++);
476 unsigned char ch2 = *(usptr2++);
477 ch1 = (
unsigned char)toupper(ch1);
478 ch2 = (
unsigned char)toupper(ch2);
479 if (ch1 == 0 || ch1 != ch2)
485static inline char *CPL_afl_friendly_strstr(
const char *haystack,
487 __attribute__((always_inline));
489static inline char *CPL_afl_friendly_strstr(
const char *haystack,
492 const char *ptr_haystack = haystack;
495 const char *ptr_haystack2 = ptr_haystack;
496 const char *ptr_needle = needle;
499 char ch1 = *(ptr_haystack2++);
500 char ch2 = *(ptr_needle++);
502 return (
char *)ptr_haystack;
506 if (*ptr_haystack == 0)
514#define memcmp CPL_afl_friendly_memcmp
515#define strcmp CPL_afl_friendly_strcmp
516#define strncmp CPL_afl_friendly_strncmp
517#define strcasecmp CPL_afl_friendly_strcasecmp
518#define strncasecmp CPL_afl_friendly_strncasecmp
519#define strstr CPL_afl_friendly_strstr
524#define STRCASECMP(a, b) (_stricmp(a, b))
525#define STRNCASECMP(a, b, n) (_strnicmp(a, b, n))
528#define STRCASECMP(a, b) (strcasecmp(a, b))
530#define STRNCASECMP(a, b, n) (strncasecmp(a, b, n))
533#define EQUALN(a, b, n) (STRNCASECMP(a, b, n) == 0)
535#define EQUAL(a, b) (STRCASECMP(a, b) == 0)
542#ifndef STARTS_WITH_CI
544#define STARTS_WITH(a, b) (strncmp(a, b, strlen(b)) == 0)
546#define STARTS_WITH_CI(a, b) EQUALN(a, b, strlen(b))
550#ifndef CPL_THREADLOCAL
551#define CPL_THREADLOCAL
555#ifndef GDAL_COMPILATION
568#define CPLIsNan(x) _isnan(x)
569#define CPLIsInf(x) (!_isnan(x) && !_finite(x))
570#define CPLIsFinite(x) _finite(x)
571#elif defined(__GNUC__) && \
572 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
575#define CPLIsNan(x) __builtin_isnan(x)
576#define CPLIsInf(x) __builtin_isinf(x)
577#define CPLIsFinite(x) __builtin_isfinite(x)
578#elif defined(__cplusplus) && defined(HAVE_STD_IS_NAN) && HAVE_STD_IS_NAN
584 static inline int CPLIsNan(
float f)
586 return std::isnan(f);
589 static inline int CPLIsNan(
double f)
591 return std::isnan(f);
594 static inline int CPLIsInf(
float f)
596 return std::isinf(f);
599 static inline int CPLIsInf(
double f)
601 return std::isinf(f);
604 static inline int CPLIsFinite(
float f)
606 return std::isfinite(f);
609 static inline int CPLIsFinite(
double f)
611 return std::isfinite(f);
616#if defined(__cplusplus) && defined(__GNUC__) && defined(__linux) && \
617 !defined(__ANDROID__) && !defined(CPL_SUPRESS_CPLUSPLUS)
622 static inline int CPLIsNan(
float f)
627 static inline int CPLIsNan(
double f)
632 static inline int CPLIsInf(
float f)
637 static inline int CPLIsInf(
double f)
642 static inline int CPLIsFinite(
float f)
644 return !__isnanf(f) && !__isinff(f);
647 static inline int CPLIsFinite(
double f)
649 return !__isnan(f) && !__isinf(f);
653#define CPLIsNan(x) isnan(x)
654#if defined(isinf) || defined(__FreeBSD__)
656#define CPLIsInf(x) isinf(x)
658#define CPLIsFinite(x) (!isnan(x) && !isinf(x))
659#elif defined(__sun__)
661#define CPLIsInf(x) (!finite(x) && !isnan(x))
662#define CPLIsFinite(x) finite(x)
664#define CPLIsInf(x) (0)
665#define CPLIsFinite(x) (!isnan(x))
680#if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB)
684#if !(defined(CPL_LSB) || defined(CPL_MSB))
695#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
701 template <
bool b>
struct CPLStaticAssert
705 template <>
struct CPLStaticAssert<true>
707 static void my_function()
714#define CPL_STATIC_ASSERT(x) CPLStaticAssert<x>::my_function()
715#define CPL_STATIC_ASSERT_IF_AVAILABLE(x) CPL_STATIC_ASSERT(x)
719#define CPL_STATIC_ASSERT_IF_AVAILABLE(x)
729#define CPL_SWAP16(x) \
730 CPL_STATIC_CAST(GUInt16, (CPL_STATIC_CAST(GUInt16, x) << 8) | \
731 (CPL_STATIC_CAST(GUInt16, x) >> 8))
733#if defined(HAVE_GCC_BSWAP)
735#define CPL_SWAP32(x) \
736 CPL_STATIC_CAST(GUInt32, __builtin_bswap32(CPL_STATIC_CAST(GUInt32, x)))
738#define CPL_SWAP64(x) \
739 CPL_STATIC_CAST(GUInt64, __builtin_bswap64(CPL_STATIC_CAST(GUInt64, x)))
740#elif defined(_MSC_VER)
741#define CPL_SWAP32(x) \
742 CPL_STATIC_CAST(GUInt32, _byteswap_ulong(CPL_STATIC_CAST(GUInt32, x)))
743#define CPL_SWAP64(x) \
744 CPL_STATIC_CAST(GUInt64, _byteswap_uint64(CPL_STATIC_CAST(GUInt64, x)))
747#define CPL_SWAP32(x) \
748 CPL_STATIC_CAST(GUInt32, \
749 ((CPL_STATIC_CAST(GUInt32, x) & 0x000000ffU) << 24) | \
750 ((CPL_STATIC_CAST(GUInt32, x) & 0x0000ff00U) << 8) | \
751 ((CPL_STATIC_CAST(GUInt32, x) & 0x00ff0000U) >> 8) | \
752 ((CPL_STATIC_CAST(GUInt32, x) & 0xff000000U) >> 24))
755#define CPL_SWAP64(x) \
756 ((CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, x))) \
758 (CPL_STATIC_CAST(GUInt64, \
759 CPL_SWAP32(CPL_STATIC_CAST( \
760 GUInt32, CPL_STATIC_CAST(GUInt64, x) >> 32)))))
765#define CPL_SWAP16PTR(x) \
770 memcpy(&_n16, _lx, 2); \
771 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || \
772 sizeof(*(x)) == 2); \
773 _n16 = CPL_SWAP16(_n16); \
774 memcpy(_lx, &_n16, 2); \
778#define CPL_SWAP32PTR(x) \
783 memcpy(&_n32, _lx, 4); \
784 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || \
785 sizeof(*(x)) == 4); \
786 _n32 = CPL_SWAP32(_n32); \
787 memcpy(_lx, &_n32, 4); \
791#define CPL_SWAP64PTR(x) \
796 memcpy(&_n64, _lx, 8); \
797 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || \
798 sizeof(*(x)) == 8); \
799 _n64 = CPL_SWAP64(_n64); \
800 memcpy(_lx, &_n64, 8); \
804#define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
807#define CPL_MSBWORD16(x) (x)
808#define CPL_LSBWORD16(x) CPL_SWAP16(x)
809#define CPL_MSBWORD32(x) (x)
810#define CPL_LSBWORD32(x) CPL_SWAP32(x)
811#define CPL_MSBPTR16(x) \
812 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
813#define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
814#define CPL_MSBPTR32(x) \
815 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
816#define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
817#define CPL_MSBPTR64(x) \
818 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
819#define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
822#define CPL_LSBWORD16(x) (x)
824#define CPL_MSBWORD16(x) CPL_SWAP16(x)
826#define CPL_LSBWORD32(x) (x)
828#define CPL_MSBWORD32(x) CPL_SWAP32(x)
831#define CPL_LSBPTR16(x) \
832 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
835#define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
838#define CPL_LSBPTR32(x) \
839 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
842#define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
845#define CPL_LSBPTR64(x) \
846 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
849#define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
855#define CPL_LSBINT16PTR(x) \
856 ((*CPL_REINTERPRET_CAST(const GByte *, x)) | \
857 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 1) << 8))
862#define CPL_LSBINT32PTR(x) \
863 ((*CPL_REINTERPRET_CAST(const GByte *, x)) | \
864 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 1) << 8) | \
865 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 2) << 16) | \
866 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 3) << 24))
869#define CPL_LSBSINT16PTR(x) CPL_STATIC_CAST(GInt16, CPL_LSBINT16PTR(x))
873#define CPL_LSBUINT16PTR(x) CPL_STATIC_CAST(GUInt16, CPL_LSBINT16PTR(x))
876#define CPL_LSBSINT32PTR(x) CPL_STATIC_CAST(GInt32, CPL_LSBINT32PTR(x))
880#define CPL_LSBUINT32PTR(x) CPL_STATIC_CAST(GUInt32, CPL_LSBINT32PTR(x))
884#ifndef UNREFERENCED_PARAM
885#ifdef UNREFERENCED_PARAMETER
886#define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param)
888#define UNREFERENCED_PARAM(param) ((void)param)
903#if defined(__GNUC__) && __GNUC__ >= 4
904#define CPL_CVSID(string) \
905 static const char cpl_cvsid[] __attribute__((used)) = string;
907#define CPL_CVSID(string) \
908 static const char cpl_cvsid[] = string; \
909 static const char *cvsid_aw() \
911 return (cvsid_aw() ? NULL : cpl_cvsid); \
915#define CPL_CVSID(string)
920#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) && \
921 !(defined(__MINGW64__) && __GNUC__ == 4 && __GNUC_MINOR__ == 6)
923#define CPL_NULL_TERMINATED __attribute__((__sentinel__))
926#define CPL_NULL_TERMINATED
929#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
931#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx) \
932 __attribute__((__format__(__printf__, format_idx, arg_idx)))
934#define CPL_SCAN_FUNC_FORMAT(format_idx, arg_idx) \
935 __attribute__((__format__(__scanf__, format_idx, arg_idx)))
938#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
940#define CPL_SCAN_FUNC_FORMAT(format_idx, arg_idx)
943#if defined(_MSC_VER) && \
944 (defined(GDAL_COMPILATION) || defined(CPL_ENABLE_MSVC_ANNOTATIONS))
948#define CPL_FORMAT_STRING(arg) _Printf_format_string_ arg
951#define CPL_SCANF_FORMAT_STRING(arg) _Scanf_format_string_ arg
954#define CPL_FORMAT_STRING(arg) arg
956#define CPL_SCANF_FORMAT_STRING(arg) arg
959#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
961#define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
964#define CPL_WARN_UNUSED_RESULT
967#if defined(__GNUC__) && __GNUC__ >= 4
969#define CPL_UNUSED __attribute((__unused__))
976#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
979#define CPL_NO_RETURN __attribute__((noreturn))
988#ifndef __has_attribute
989#define __has_attribute(x) 0
994#if ((defined(__GNUC__) && \
995 (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) || \
996 __has_attribute(returns_nonnull)) && \
997 !defined(DOXYGEN_SKIP) && !defined(__INTEL_COMPILER)
999#define CPL_RETURNS_NONNULL __attribute__((returns_nonnull))
1002#define CPL_RETURNS_NONNULL
1005#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
1007#define CPL_RESTRICT __restrict__
1013#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
1017#define CPL_OVERRIDE override
1020#define CPL_FINAL final
1023#define CPL_NON_FINAL
1030#define CPL_DISALLOW_COPY_ASSIGN(ClassName) \
1031 ClassName(const ClassName &) = delete; \
1032 ClassName &operator=(const ClassName &) = delete;
1036#if !defined(DOXYGEN_SKIP) && !defined(CPL_WARN_DEPRECATED)
1037#if defined(__has_extension)
1038#if __has_extension(attribute_deprecated_with_message)
1040#define CPL_WARN_DEPRECATED(x) __attribute__((deprecated(x)))
1042#define CPL_WARN_DEPRECATED(x)
1044#elif defined(__GNUC__)
1045#define CPL_WARN_DEPRECATED(x) __attribute__((deprecated))
1047#define CPL_WARN_DEPRECATED(x)
1051#if !defined(_MSC_VER) && !defined(__APPLE__) && !defined(_FORTIFY_SOURCE)
1053#if defined(GDAL_COMPILATION) && defined(WARN_STANDARD_PRINTF)
1054int vsnprintf(
char *str,
size_t size,
const char *fmt, va_list args)
1055 CPL_WARN_DEPRECATED(
"Use CPLvsnprintf() instead");
1056int snprintf(
char *str,
size_t size,
const char *fmt, ...)
1058 CPL_WARN_DEPRECATED("Use CPLsnprintf() instead");
1060 CPL_WARN_DEPRECATED("Use CPLsnprintf() instead");
1061#elif defined(GDAL_COMPILATION) && !defined(DONT_DEPRECATE_SPRINTF)
1063 CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
1068#if defined(__cplusplus)
1071#define CPL_ARRAYSIZE(array) \
1072 ((sizeof(array) / sizeof(*(array))) / \
1073 static_cast<size_t>(!(sizeof(array) % sizeof(*(array)))))
1076#define CPL_ARRAYSIZE(array) (sizeof(array) / sizeof(array[0]))
1081 template <
class T>
static void CPL_IGNORE_RET_VAL(
const T &)
1085 inline static bool CPL_TO_BOOL(
int x)
1093#if (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || \
1094 (defined(__clang__) && __clang_major__ >= 3)) && \
1096#define HAVE_GCC_DIAGNOSTIC_PUSH
1099#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) && \
1101#define HAVE_GCC_SYSTEM_HEADER
1114#if __clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 8)
1115#define CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW \
1116 __attribute__((no_sanitize("unsigned-integer-overflow")))
1118#define CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW
1121#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && \
1122 defined(GDAL_COMPILATION)
1125 template <
class C,
class A,
class B>
1126 CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW
inline C CPLUnsanitizedAdd(A a, B b)
1133#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
1134#define CPL_NULLPTR nullptr
1136#define CPL_NULLPTR NULL
1139#if defined(__cplusplus) && defined(GDAL_COMPILATION)
1148 template <
typename T>
inline T fits_on(T t)
1154 template <
typename C,
typename V>
1155 inline bool contains(
const C &container,
const V &value)
1157 return container.find(value) != container.end();
1171#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && \
1172 !defined(DOXYGEN_SKIP)
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition cpl_port.h:240
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:202
short GInt16
Int16 type.
Definition cpl_port.h:165
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:283
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:279
GIntBig GInt64
Signed 64 bit integer type.
Definition cpl_port.h:220
int GBool
Type for boolean values (alias to int)
Definition cpl_port.h:180
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:161
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition cpl_port.h:938
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1179
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:222
unsigned short GUInt16
Unsigned int16 type.
Definition cpl_port.h:167
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:169
int GInt32
Int32 type.
Definition cpl_port.h:159
signed char GInt8
Signed int8 type.
Definition cpl_port.h:171
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:199