15#ifndef CPL_BASE_H_INCLUDED
16#define CPL_BASE_H_INCLUDED
30#ifndef _CRT_SECURE_NO_DEPRECATE
31#define _CRT_SECURE_NO_DEPRECATE
33#ifndef _CRT_NONSTDC_NO_DEPRECATE
34#define _CRT_NONSTDC_NO_DEPRECATE
38#include "cpl_config.h"
45#if !defined(SIZEOF_INT) || SIZEOF_INT != 4
46#error "Unexpected value for SIZEOF_INT"
49#if !defined(SIZEOF_UNSIGNED_LONG) || \
50 (SIZEOF_UNSIGNED_LONG != 4 && SIZEOF_UNSIGNED_LONG != 8)
51#error "Unexpected value for SIZEOF_UNSIGNED_LONG"
54#if !defined(SIZEOF_VOIDP)
55#error "Unexpected value for SIZEOF_VOIDP"
68#if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE)
69#define _LARGEFILE64_SOURCE 1
78#if defined(HAVE_ICONV)
79#define CPL_RECODE_ICONV
82#define CPL_RECODE_STUB
90#if defined(GDAL_COMPILATION) && defined(__sun__) && \
91 (__STDC_VERSION__ + 0) >= 201112L && (_XOPEN_SOURCE + 0) < 600
95#define _XOPEN_SOURCE 600
145#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
146#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900))
147#error Must have C++11 or newer.
149#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
152#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
181#ifndef CPL_GBOOL_DEFINED
183#define CPL_GBOOL_DEFINED
191#define CPL_STATIC_CAST(type, expr) static_cast<type>(expr)
192#define CPL_REINTERPRET_CAST(type, expr) reinterpret_cast<type>(expr)
194#define CPL_STATIC_CAST(type, expr) ((type)(expr))
195#define CPL_REINTERPRET_CAST(type, expr) ((type)(expr))
211#define GINTBIG_MIN (CPL_STATIC_CAST(GIntBig, 0x80000000) << 32)
213#define GINTBIG_MAX ((CPL_STATIC_CAST(GIntBig, 0x7FFFFFFF) << 32) | 0xFFFFFFFFU)
215#define GUINTBIG_MAX \
216 ((CPL_STATIC_CAST(GUIntBig, 0xFFFFFFFFU) << 32) | 0xFFFFFFFFU)
219#define CPL_HAS_GINT64 1
231#define GINT64_MIN GINTBIG_MIN
233#define GINT64_MAX GINTBIG_MAX
235#define GUINT64_MAX GUINTBIG_MAX
241#elif SIZEOF_VOIDP == 8
249#ifdef GDAL_COMPILATION
251typedef uintptr_t GUIntptr_t;
252#define CPL_IS_ALIGNED(ptr, quant) \
253 ((CPL_REINTERPRET_CAST(GUIntptr_t, CPL_STATIC_CAST(const void *, ptr)) % \
258#if (defined(__MSVCRT__) && !(defined(__MINGW64__) && __GNUC__ >= 10)) || \
259 (defined(_WIN32) && defined(_MSC_VER))
260#define CPL_FRMT_GB_WITHOUT_PREFIX "I64"
263#define CPL_FRMT_GB_WITHOUT_PREFIX "ll"
267#define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d"
269#define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u"
272#ifdef COMPAT_WITH_ICC_CONVERSION_CHECK
273#define CPL_INT64_FITS_ON_INT32(x) ((x) >= INT_MIN && (x) <= INT_MAX)
275#define CPL_INT64_FITS_ON_INT32(x) \
276 (CPL_STATIC_CAST(GIntBig, CPL_STATIC_CAST(int, x)) == (x))
296#if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
297#ifdef GDAL_COMPILATION
298#define CPL_DLL __declspec(dllexport)
304#if defined(USE_GCC_VISIBILITY_FLAG)
305#define CPL_DLL __attribute__((visibility("default")))
306#if !defined(__MINGW32__)
307#define CPL_INTERNAL __attribute__((visibility("hidden")))
318#define CPL_UNSTABLE_API CPL_DLL
324#ifdef CPL_OPTIONAL_APIS
325#define CPL_ODLL CPL_DLL
332#if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL)
333#define CPL_STDCALL __stdcall
341#define FORCE_CDECL __cdecl
349#if (defined(__GNUC__) && !defined(__NO_INLINE__)) || defined(_MSC_VER)
350#define HAS_CPL_INLINE 1
351#define CPL_INLINE __inline
352#elif defined(__SUNPRO_CC)
353#define HAS_CPL_INLINE 1
354#define CPL_INLINE inline
362#define MIN(a, b) (((a) < (b)) ? (a) : (b))
364#define MAX(a, b) (((a) > (b)) ? (a) : (b))
369#define ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
374#define M_PI 3.14159265358979323846
385#define CPLIsEqual(x, y) (fabs((x) - (y)) < 0.0000000000001)
394#if defined(AFL_FRIENDLY) && defined(__GNUC__)
396static inline int CPL_afl_friendly_memcmp(
const void *ptr1,
const void *ptr2,
398 __attribute__((always_inline));
400static inline int CPL_afl_friendly_memcmp(
const void *ptr1,
const void *ptr2,
403 const unsigned char *bptr1 = (
const unsigned char *)ptr1;
404 const unsigned char *bptr2 = (
const unsigned char *)ptr2;
407 unsigned char b1 = *(bptr1++);
408 unsigned char b2 = *(bptr2++);
415static inline int CPL_afl_friendly_strcmp(
const char *ptr1,
const char *ptr2)
416 __attribute__((always_inline));
418static inline int CPL_afl_friendly_strcmp(
const char *ptr1,
const char *ptr2)
420 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
421 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
424 unsigned char ch1 = *(usptr1++);
425 unsigned char ch2 = *(usptr2++);
426 if (ch1 == 0 || ch1 != ch2)
431static inline int CPL_afl_friendly_strncmp(
const char *ptr1,
const char *ptr2,
433 __attribute__((always_inline));
435static inline int CPL_afl_friendly_strncmp(
const char *ptr1,
const char *ptr2,
438 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
439 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
442 unsigned char ch1 = *(usptr1++);
443 unsigned char ch2 = *(usptr2++);
444 if (ch1 == 0 || ch1 != ch2)
450static inline int CPL_afl_friendly_strcasecmp(
const char *ptr1,
452 __attribute__((always_inline));
454static inline int CPL_afl_friendly_strcasecmp(
const char *ptr1,
457 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
458 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
461 unsigned char ch1 = *(usptr1++);
462 unsigned char ch2 = *(usptr2++);
463 ch1 = (
unsigned char)toupper(ch1);
464 ch2 = (
unsigned char)toupper(ch2);
465 if (ch1 == 0 || ch1 != ch2)
470static inline int CPL_afl_friendly_strncasecmp(
const char *ptr1,
471 const char *ptr2,
size_t len)
472 __attribute__((always_inline));
474static inline int CPL_afl_friendly_strncasecmp(
const char *ptr1,
475 const char *ptr2,
size_t len)
477 const unsigned char *usptr1 = (
const unsigned char *)ptr1;
478 const unsigned char *usptr2 = (
const unsigned char *)ptr2;
481 unsigned char ch1 = *(usptr1++);
482 unsigned char ch2 = *(usptr2++);
483 ch1 = (
unsigned char)toupper(ch1);
484 ch2 = (
unsigned char)toupper(ch2);
485 if (ch1 == 0 || ch1 != ch2)
491static inline char *CPL_afl_friendly_strstr(
const char *haystack,
493 __attribute__((always_inline));
495static inline char *CPL_afl_friendly_strstr(
const char *haystack,
498 const char *ptr_haystack = haystack;
501 const char *ptr_haystack2 = ptr_haystack;
502 const char *ptr_needle = needle;
505 char ch1 = *(ptr_haystack2++);
506 char ch2 = *(ptr_needle++);
508 return (
char *)ptr_haystack;
512 if (*ptr_haystack == 0)
520#define memcmp CPL_afl_friendly_memcmp
521#define strcmp CPL_afl_friendly_strcmp
522#define strncmp CPL_afl_friendly_strncmp
523#define strcasecmp CPL_afl_friendly_strcasecmp
524#define strncasecmp CPL_afl_friendly_strncasecmp
525#define strstr CPL_afl_friendly_strstr
530#define STRCASECMP(a, b) (_stricmp(a, b))
531#define STRNCASECMP(a, b, n) (_strnicmp(a, b, n))
534#define STRCASECMP(a, b) (strcasecmp(a, b))
536#define STRNCASECMP(a, b, n) (strncasecmp(a, b, n))
539#define EQUALN(a, b, n) (STRNCASECMP(a, b, n) == 0)
541#define EQUAL(a, b) (STRCASECMP(a, b) == 0)
548#ifndef STARTS_WITH_CI
550#define STARTS_WITH(a, b) (strncmp(a, b, strlen(b)) == 0)
552#define STARTS_WITH_CI(a, b) EQUALN(a, b, strlen(b))
556#ifndef CPL_THREADLOCAL
557#define CPL_THREADLOCAL
574#define CPLIsNan(x) _isnan(x)
575#define CPLIsInf(x) (!_isnan(x) && !_finite(x))
576#define CPLIsFinite(x) _finite(x)
577#elif defined(__GNUC__) && \
578 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
581#define CPLIsNan(x) __builtin_isnan(x)
582#define CPLIsInf(x) __builtin_isinf(x)
583#define CPLIsFinite(x) __builtin_isfinite(x)
584#elif defined(isinf) || defined(__FreeBSD__)
586#define CPLIsNan(x) isnan(x)
588#define CPLIsInf(x) isinf(x)
590#define CPLIsFinite(x) (!isnan(x) && !isinf(x))
591#elif defined(__sun__)
593#define CPLIsNan(x) isnan(x)
594#define CPLIsInf(x) (!finite(x) && !isnan(x))
595#define CPLIsFinite(x) finite(x)
597#define CPLIsNan(x) ((x) != (x))
598#define CPLIsInf(x) (0)
599#define CPLIsFinite(x) (!isnan(x))
612#if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB)
616#if !(defined(CPL_LSB) || defined(CPL_MSB))
627#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
633 template <
bool b>
struct CPLStaticAssert
637 template <>
struct CPLStaticAssert<true>
639 static void my_function()
646#define CPL_STATIC_ASSERT(x) CPLStaticAssert<x>::my_function()
647#define CPL_STATIC_ASSERT_IF_AVAILABLE(x) CPL_STATIC_ASSERT(x)
651#define CPL_STATIC_ASSERT_IF_AVAILABLE(x)
661#define CPL_SWAP16(x) \
662 CPL_STATIC_CAST(GUInt16, (CPL_STATIC_CAST(GUInt16, x) << 8) | \
663 (CPL_STATIC_CAST(GUInt16, x) >> 8))
667#define CPL_SWAP32(x) \
668 CPL_STATIC_CAST(GUInt32, __builtin_bswap32(CPL_STATIC_CAST(GUInt32, x)))
670#define CPL_SWAP64(x) \
671 CPL_STATIC_CAST(GUInt64, __builtin_bswap64(CPL_STATIC_CAST(GUInt64, x)))
672#elif defined(_MSC_VER)
673#define CPL_SWAP32(x) \
674 CPL_STATIC_CAST(GUInt32, _byteswap_ulong(CPL_STATIC_CAST(GUInt32, x)))
675#define CPL_SWAP64(x) \
676 CPL_STATIC_CAST(GUInt64, _byteswap_uint64(CPL_STATIC_CAST(GUInt64, x)))
679#define CPL_SWAP32(x) \
680 CPL_STATIC_CAST(GUInt32, \
681 ((CPL_STATIC_CAST(GUInt32, x) & 0x000000ffU) << 24) | \
682 ((CPL_STATIC_CAST(GUInt32, x) & 0x0000ff00U) << 8) | \
683 ((CPL_STATIC_CAST(GUInt32, x) & 0x00ff0000U) >> 8) | \
684 ((CPL_STATIC_CAST(GUInt32, x) & 0xff000000U) >> 24))
687#define CPL_SWAP64(x) \
688 ((CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, x))) \
690 (CPL_STATIC_CAST(GUInt64, \
691 CPL_SWAP32(CPL_STATIC_CAST( \
692 GUInt32, CPL_STATIC_CAST(GUInt64, x) >> 32)))))
697#define CPL_SWAP16PTR(x) \
702 memcpy(&_n16, _lx, 2); \
703 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || \
704 sizeof(*(x)) == 2); \
705 _n16 = CPL_SWAP16(_n16); \
706 memcpy(_lx, &_n16, 2); \
710#define CPL_SWAP32PTR(x) \
715 memcpy(&_n32, _lx, 4); \
716 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || \
717 sizeof(*(x)) == 4); \
718 _n32 = CPL_SWAP32(_n32); \
719 memcpy(_lx, &_n32, 4); \
723#define CPL_SWAP64PTR(x) \
728 memcpy(&_n64, _lx, 8); \
729 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || \
730 sizeof(*(x)) == 8); \
731 _n64 = CPL_SWAP64(_n64); \
732 memcpy(_lx, &_n64, 8); \
736#define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
739#define CPL_MSBWORD16(x) (x)
740#define CPL_LSBWORD16(x) CPL_SWAP16(x)
741#define CPL_MSBWORD32(x) (x)
742#define CPL_LSBWORD32(x) CPL_SWAP32(x)
743#define CPL_MSBPTR16(x) \
744 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
745#define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
746#define CPL_MSBPTR32(x) \
747 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
748#define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
749#define CPL_MSBPTR64(x) \
750 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
751#define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
754#define CPL_LSBWORD16(x) (x)
756#define CPL_MSBWORD16(x) CPL_SWAP16(x)
758#define CPL_LSBWORD32(x) (x)
760#define CPL_MSBWORD32(x) CPL_SWAP32(x)
763#define CPL_LSBPTR16(x) \
764 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
767#define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
770#define CPL_LSBPTR32(x) \
771 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
774#define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
777#define CPL_LSBPTR64(x) \
778 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
781#define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
787#define CPL_LSBINT16PTR(x) \
788 ((*CPL_REINTERPRET_CAST(const GByte *, x)) | \
789 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 1) << 8))
794#define CPL_LSBINT32PTR(x) \
795 ((*CPL_REINTERPRET_CAST(const GByte *, x)) | \
796 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 1) << 8) | \
797 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 2) << 16) | \
798 (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 3) << 24))
801#define CPL_LSBSINT16PTR(x) CPL_STATIC_CAST(GInt16, CPL_LSBINT16PTR(x))
805#define CPL_LSBUINT16PTR(x) CPL_STATIC_CAST(GUInt16, CPL_LSBINT16PTR(x))
808#define CPL_LSBSINT32PTR(x) CPL_STATIC_CAST(GInt32, CPL_LSBINT32PTR(x))
812#define CPL_LSBUINT32PTR(x) CPL_STATIC_CAST(GUInt32, CPL_LSBINT32PTR(x))
816#ifndef UNREFERENCED_PARAM
817#ifdef UNREFERENCED_PARAMETER
818#define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param)
820#define UNREFERENCED_PARAM(param) ((void)param)
826#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) && \
827 !(defined(__MINGW64__) && __GNUC__ == 4 && __GNUC_MINOR__ == 6)
829#define CPL_NULL_TERMINATED __attribute__((__sentinel__))
832#define CPL_NULL_TERMINATED
835#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
837#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx) \
838 __attribute__((__format__(__printf__, format_idx, arg_idx)))
840#define CPL_SCAN_FUNC_FORMAT(format_idx, arg_idx) \
841 __attribute__((__format__(__scanf__, format_idx, arg_idx)))
844#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
846#define CPL_SCAN_FUNC_FORMAT(format_idx, arg_idx)
849#if defined(_MSC_VER) && \
850 (defined(GDAL_COMPILATION) || defined(CPL_ENABLE_MSVC_ANNOTATIONS))
854#define CPL_FORMAT_STRING(arg) _Printf_format_string_ arg
857#define CPL_SCANF_FORMAT_STRING(arg) _Scanf_format_string_ arg
860#define CPL_FORMAT_STRING(arg) arg
862#define CPL_SCANF_FORMAT_STRING(arg) arg
865#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
867#define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
870#define CPL_WARN_UNUSED_RESULT
873#if defined(__GNUC__) && __GNUC__ >= 4
875#define CPL_UNUSED __attribute((__unused__))
882#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
885#define CPL_NO_RETURN __attribute__((noreturn))
894#ifndef __has_attribute
895#define __has_attribute(x) 0
900#if ((defined(__GNUC__) && \
901 (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) || \
902 __has_attribute(returns_nonnull)) && \
903 !defined(DOXYGEN_SKIP) && !defined(__INTEL_COMPILER)
905#define CPL_RETURNS_NONNULL __attribute__((returns_nonnull))
908#define CPL_RETURNS_NONNULL
911#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
913#define CPL_RESTRICT __restrict__
919#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
923#define CPL_OVERRIDE override
926#define CPL_FINAL final
936#define CPL_DISALLOW_COPY_ASSIGN(ClassName) \
937 ClassName(const ClassName &) = delete; \
938 ClassName &operator=(const ClassName &) = delete;
942#ifdef CPL_DISABLE_WARN_DEPRECATED
943#define CPL_WARN_DEPRECATED(x)
944#elif !defined(DOXYGEN_SKIP) && !defined(CPL_WARN_DEPRECATED)
945#if defined(__has_extension)
946#if __has_extension(attribute_deprecated_with_message)
948#define CPL_WARN_DEPRECATED(x) __attribute__((deprecated(x)))
950#define CPL_WARN_DEPRECATED(x)
952#elif defined(__GNUC__)
953#define CPL_WARN_DEPRECATED(x) __attribute__((deprecated))
955#define CPL_WARN_DEPRECATED(x)
959#if !defined(_MSC_VER) && !defined(__APPLE__) && !defined(_FORTIFY_SOURCE)
961#if defined(GDAL_COMPILATION) && defined(WARN_STANDARD_PRINTF)
962int vsnprintf(
char *str,
size_t size,
const char *fmt, va_list args)
963 CPL_WARN_DEPRECATED(
"Use CPLvsnprintf() instead");
964int snprintf(
char *str,
size_t size,
const char *fmt, ...)
966 CPL_WARN_DEPRECATED(
"Use CPLsnprintf() instead");
968 CPL_WARN_DEPRECATED(
"Use CPLsnprintf() instead");
969#elif defined(GDAL_COMPILATION) && !defined(DONT_DEPRECATE_SPRINTF)
971 CPL_WARN_DEPRECATED(
"Use snprintf() or CPLsnprintf() instead");
976#if defined(__cplusplus)
979#define CPL_ARRAYSIZE(array) \
980 ((sizeof(array) / sizeof(*(array))) / \
981 static_cast<size_t>(!(sizeof(array) % sizeof(*(array)))))
984#define CPL_ARRAYSIZE(array) (sizeof(array) / sizeof(array[0]))
989 template <
class T>
static void CPL_IGNORE_RET_VAL(
const T &)
993 inline static bool CPL_TO_BOOL(
int x)
1001#if (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || \
1002 (defined(__clang__) && __clang_major__ >= 3)) && \
1004#define HAVE_GCC_DIAGNOSTIC_PUSH
1007#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) && \
1009#define HAVE_GCC_SYSTEM_HEADER
1022#if __clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 8)
1023#define CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW \
1024 __attribute__((no_sanitize("unsigned-integer-overflow")))
1026#define CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW
1029#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && \
1030 defined(GDAL_COMPILATION)
1033 template <
class C,
class A,
class B>
1034 CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW
inline C CPLUnsanitizedAdd(A a, B b)
1041#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
1042#define CPL_NULLPTR nullptr
1044#define CPL_NULLPTR NULL
1047#if defined(__cplusplus) && defined(GDAL_COMPILATION)
1056 template <
typename T>
inline T fits_on(T t)
1062 template <
typename C,
typename V>
1063 inline bool contains(
const C &container,
const V &value)
1065 return container.find(value) != container.end();
1079#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && \
1080 !defined(DOXYGEN_SKIP)
1090#if defined(__cplusplus) && defined(GDAL_COMPILATION)
1091#if defined(__GNUC__) && !defined(DOXYGEN_SKIP)
1095#define CPL_UNLIKELY(cond) __builtin_expect(static_cast<bool>(cond), 0)
1097#define CPL_UNLIKELY(cond) (cond)
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition cpl_port.h:246
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:208
short GInt16
Int16 type.
Definition cpl_port.h:171
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285
GIntBig GInt64
Signed 64 bit integer type.
Definition cpl_port.h:226
int GBool
Type for boolean values (alias to int).
Definition cpl_port.h:186
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:167
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition cpl_port.h:844
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:228
unsigned short GUInt16
Unsigned int16 type.
Definition cpl_port.h:173
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
int GInt32
Int32 type.
Definition cpl_port.h:165
signed char GInt8
Signed int8 type.
Definition cpl_port.h:177
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205