GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

cpl_port.h
Go to the documentation of this file.
1 /******************************************************************************
2 * $Id$
3 *
4 * Project: CPL - Common Portability Library
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 * Purpose: Include file providing low level portability services for CPL.
7 * This should be the first include file for any CPL based code.
8 *
9 ******************************************************************************
10 * Copyright (c) 1998, 2005, Frank Warmerdam <warmerdam@pobox.com>
11 * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included
21 * in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 * DEALINGS IN THE SOFTWARE.
30 ****************************************************************************/
31
32 #ifndef CPL_BASE_H_INCLUDED
33 #define CPL_BASE_H_INCLUDED
34
42 /* ==================================================================== */
43 /* We will use WIN32 as a standard windows define. */
44 /* ==================================================================== */
45 #if defined(_WIN32) && !defined(WIN32)
46 # define WIN32
47 #endif
48
49 #if defined(_WINDOWS) && !defined(WIN32)
50 # define WIN32
51 #endif
52
53 /* -------------------------------------------------------------------- */
54 /* The following apparently allow you to use strcpy() and other */
55 /* functions judged "unsafe" by microsoft in VS 8 (2005). */
56 /* -------------------------------------------------------------------- */
57 #ifdef _MSC_VER
58 # ifndef _CRT_SECURE_NO_DEPRECATE
59 # define _CRT_SECURE_NO_DEPRECATE
60 # endif
61 # ifndef _CRT_NONSTDC_NO_DEPRECATE
62 # define _CRT_NONSTDC_NO_DEPRECATE
63 # endif
64 #endif
65
66 #include "cpl_config.h"
67
68 /* ==================================================================== */
69 /* A few sanity checks, mainly to detect problems that sometimes */
70 /* arise with bad configured cross-compilation. */
71 /* ==================================================================== */
72
73 #if !defined(SIZEOF_INT) || SIZEOF_INT != 4
74 #error "Unexpected value for SIZEOF_INT"
75 #endif
76
77 #if !defined(SIZEOF_UNSIGNED_LONG) || (SIZEOF_UNSIGNED_LONG != 4 && SIZEOF_UNSIGNED_LONG != 8)
78 #error "Unexpected value for SIZEOF_UNSIGNED_LONG"
79 #endif
80
81 #if !defined(SIZEOF_VOIDP) || (SIZEOF_VOIDP != 4 && SIZEOF_VOIDP != 8)
82 #error "Unexpected value for SIZEOF_VOIDP"
83 #endif
84
85 /* ==================================================================== */
86 /* This will disable most WIN32 stuff in a Cygnus build which */
87 /* defines unix to 1. */
88 /* ==================================================================== */
89
90 #ifdef unix
91 # undef WIN32
92 #endif
93
95 #if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE)
96 # define _LARGEFILE64_SOURCE 1
97 #endif
98
99 /* ==================================================================== */
100 /* If iconv() is available use extended recoding module. */
101 /* Stub implementation is always compiled in, because it works */
102 /* faster than iconv() for encodings it supports. */
103 /* ==================================================================== */
104
105 #if defined(HAVE_ICONV)
106 # define CPL_RECODE_ICONV
107 #endif
108
109 #define CPL_RECODE_STUB
110
112 /* ==================================================================== */
113 /* MinGW stuff */
114 /* ==================================================================== */
115
116 /* We need __MSVCRT_VERSION__ >= 0x0700 to have "_aligned_malloc" */
117 /* Latest versions of mingw32 define it, but with older ones, */
118 /* we need to define it manually */
119 #if defined(__MINGW32__)
120 #ifndef __MSVCRT_VERSION__
121 #define __MSVCRT_VERSION__ 0x0700
122 #endif
123 #endif
124
125 /* Needed for std=c11 on Solaris to have strcasecmp() */
126 #if defined(GDAL_COMPILATION) && defined(__sun__) && (__STDC_VERSION__ + 0) >= 201112L && (_XOPEN_SOURCE + 0) < 600
127 #ifdef _XOPEN_SOURCE
128 #undef _XOPEN_SOURCE
129 #endif
130 #define _XOPEN_SOURCE 600
131 #endif
132
133 /* ==================================================================== */
134 /* Standard include files. */
135 /* ==================================================================== */
136
137 #include <stdio.h>
138 #include <stdlib.h>
139 #include <math.h>
140 #include <stdarg.h>
141 #include <string.h>
142 #include <ctype.h>
143 #include <limits.h>
144
145 #include <time.h>
146
147 #if defined(HAVE_ERRNO_H)
148 # include <errno.h>
149 #endif
150
151 #ifdef HAVE_LOCALE_H
152 # include <locale.h>
153 #endif
154
155 #ifdef HAVE_DIRECT_H
156 # include <direct.h>
157 #endif
158
159 #if !defined(WIN32)
160 # include <strings.h>
161 #endif
162
163 #if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG)
164 # define DBMALLOC
165 # include <dbmalloc.h>
166 #endif
167
168 #if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H)
169 # define USE_DMALLOC
170 # include <dmalloc.h>
171 #endif
172
173 /* ==================================================================== */
174 /* Base portability stuff ... this stuff may need to be */
175 /* modified for new platforms. */
176 /* ==================================================================== */
177
178 /* -------------------------------------------------------------------- */
179 /* Which versions of C++ are available. */
180 /* -------------------------------------------------------------------- */
181
182 /* MSVC fails to define a decent value of __cplusplus. Try to target VS2015*/
183 /* as a minimum */
184
185 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
186 # if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900))
187 # error Must have C++11 or newer.
188 # endif
189 # if __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
190 # define HAVE_CXX14 1
191 # endif
192 # if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
193 # define HAVE_CXX17 1
194 # endif
195 #endif /* __cplusplus */
196
197 /*---------------------------------------------------------------------
198 * types for 16 and 32 bits integers, etc...
199 *--------------------------------------------------------------------*/
200 #if UINT_MAX == 65535
201 typedef long GInt32;
202 typedef unsigned long GUInt32;
203 #else
204
205 typedef int GInt32;
207 typedef unsigned int GUInt32;
208 #endif
209
211 typedef short GInt16;
213 typedef unsigned short GUInt16;
215 typedef unsigned char GByte;
216 /* hack for PDF driver and poppler >= 0.15.0 that defines incompatible "typedef bool GBool" */
217 /* in include/poppler/goo/gtypes.h */
218 #ifndef CPL_GBOOL_DEFINED
219
220 #define CPL_GBOOL_DEFINED
221
223 typedef int GBool;
224 #endif
225
227 #ifdef __cplusplus
228 #define CPL_STATIC_CAST(type, expr) static_cast<type>(expr)
229 #define CPL_REINTERPRET_CAST(type, expr) reinterpret_cast<type>(expr)
230 #else
231 #define CPL_STATIC_CAST(type, expr) ((type)(expr))
232 #define CPL_REINTERPRET_CAST(type, expr) ((type)(expr))
233 #endif
234
236 /* -------------------------------------------------------------------- */
237 /* 64bit support */
238 /* -------------------------------------------------------------------- */
239
240 #if defined(WIN32) && defined(_MSC_VER)
241 #define VSI_LARGE_API_SUPPORTED
242 #endif
243
244 #if HAVE_LONG_LONG
245
248 typedef long long GIntBig;
251 typedef unsigned long long GUIntBig;
252
254 #define GINTBIG_MIN (CPL_STATIC_CAST(GIntBig, 0x80000000) << 32)
255
256 #define GINTBIG_MAX ((CPL_STATIC_CAST(GIntBig, 0x7FFFFFFF) << 32) | 0xFFFFFFFFU)
257
258 #define GUINTBIG_MAX ((CPL_STATIC_CAST(GUIntBig, 0xFFFFFFFFU) << 32) | 0xFFFFFFFFU)
259
261 #define CPL_HAS_GINT64 1
262
264 /* Note: we might want to use instead int64_t / uint64_t if they are available */
265
267 typedef GIntBig GInt64;
269 typedef GUIntBig GUInt64;
270
272 #define GINT64_MIN GINTBIG_MIN
273
274 #define GINT64_MAX GINTBIG_MAX
275
276 #define GUINT64_MAX GUINTBIG_MAX
277
278 #else
279
280 #error "64bit integer support required"
281
282 #endif
283
284 #if SIZEOF_VOIDP == 8
285
286 typedef GIntBig GPtrDiff_t;
287 #else
288
289 typedef int GPtrDiff_t;
290 #endif
291
292 #ifdef GDAL_COMPILATION
293 #if HAVE_UINTPTR_T
294 #include <stdint.h>
295 typedef uintptr_t GUIntptr_t;
296 #elif SIZEOF_VOIDP == 8
297 typedef GUIntBig GUIntptr_t;
298 #else
299 typedef unsigned int GUIntptr_t;
300 #endif
301
302 #define CPL_IS_ALIGNED(ptr, quant) ((CPL_REINTERPRET_CAST(GUIntptr_t, CPL_STATIC_CAST(const void*, ptr)) % (quant)) == 0)
303
304 #endif
305
306 #if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER))
307 #define CPL_FRMT_GB_WITHOUT_PREFIX "I64"
308 #elif HAVE_LONG_LONG
309
310 #define CPL_FRMT_GB_WITHOUT_PREFIX "ll"
311 #else
312 #define CPL_FRMT_GB_WITHOUT_PREFIX "l"
313 #endif
314
316 #define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d"
317
318 #define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u"
319
321 #define GUINTBIG_TO_DOUBLE(x) CPL_STATIC_CAST(double, x)
322
325 #ifdef COMPAT_WITH_ICC_CONVERSION_CHECK
326 #define CPL_INT64_FITS_ON_INT32(x) ((x) >= INT_MIN && (x) <= INT_MAX)
327 #else
328 #define CPL_INT64_FITS_ON_INT32(x) (CPL_STATIC_CAST(GIntBig, CPL_STATIC_CAST(int, x)) == (x))
329 #endif
330
332 /* ==================================================================== */
333 /* Other standard services. */
334 /* ==================================================================== */
335 #ifdef __cplusplus
336
337 # define CPL_C_START extern "C" {
338
339 # define CPL_C_END }
340 #else
341 # define CPL_C_START
342 # define CPL_C_END
343 #endif
344
345 #ifndef CPL_DLL
346 #if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
347 # define CPL_DLL __declspec(dllexport)
348 # define CPL_INTERNAL
349 #else
350 # if defined(USE_GCC_VISIBILITY_FLAG)
351 # define CPL_DLL __attribute__ ((visibility("default")))
352 # if !defined(__MINGW32__)
353 # define CPL_INTERNAL __attribute__((visibility("hidden")))
354 # else
355 # define CPL_INTERNAL
356 # endif
357 # else
358 # define CPL_DLL
359 # define CPL_INTERNAL
360 # endif
361 #endif
362
363 // Marker for unstable API
364 #define CPL_UNSTABLE_API CPL_DLL
365
366 #endif
367
369 /* Should optional (normally private) interfaces be exported? */
370 #ifdef CPL_OPTIONAL_APIS
371 # define CPL_ODLL CPL_DLL
372 #else
373 # define CPL_ODLL
374 #endif
375
377 #ifndef CPL_STDCALL
378 #if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL)
379 # define CPL_STDCALL __stdcall
380 #else
381 # define CPL_STDCALL
382 #endif
383 #endif
384
386 #ifdef _MSC_VER
387 # define FORCE_CDECL __cdecl
388 #else
389 # define FORCE_CDECL
390 #endif
391
394 /* TODO : support for other compilers needed */
395 #if (defined(__GNUC__) && !defined(__NO_INLINE__)) || defined(_MSC_VER)
396 #define HAS_CPL_INLINE 1
397 #define CPL_INLINE __inline
398 #elif defined(__SUNPRO_CC)
399 #define HAS_CPL_INLINE 1
400 #define CPL_INLINE inline
401 #else
402 #define CPL_INLINE
403 #endif
404
406 #ifndef MAX
407
408 # define MIN(a,b) (((a)<(b)) ? (a) : (b))
409
410 # define MAX(a,b) (((a)>(b)) ? (a) : (b))
411 #endif
412
413 #ifndef ABS
414
415 # define ABS(x) (((x)<0) ? (-1*(x)) : (x))
416 #endif
417
418 #ifndef M_PI
419
420 # define M_PI 3.14159265358979323846
421 /* 3.1415926535897932384626433832795 */
422 #endif
423
424 /* -------------------------------------------------------------------- */
425 /* Macro to test equality of two floating point values. */
426 /* We use fabs() function instead of ABS() macro to avoid side */
427 /* effects. */
428 /* -------------------------------------------------------------------- */
430 #ifndef CPLIsEqual
431 # define CPLIsEqual(x,y) (fabs((x) - (y)) < 0.0000000000001)
432 #endif
433
435 /* -------------------------------------------------------------------- */
436 /* Provide macros for case insensitive string comparisons. */
437 /* -------------------------------------------------------------------- */
438 #ifndef EQUAL
439
440 #if defined(AFL_FRIENDLY) && defined(__GNUC__)
441
442 static inline int CPL_afl_friendly_memcmp(const void* ptr1, const void* ptr2, size_t len)
443 __attribute__((always_inline));
444
445 static inline int CPL_afl_friendly_memcmp(const void* ptr1, const void* ptr2, size_t len)
446 {
447 const unsigned char* bptr1 = (const unsigned char*)ptr1;
448 const unsigned char* bptr2 = (const unsigned char*)ptr2;
449 while( len-- )
450 {
451 unsigned char b1 = *(bptr1++);
452 unsigned char b2 = *(bptr2++);
453 if( b1 != b2 ) return b1 - b2;
454 }
455 return 0;
456 }
457
458 static inline int CPL_afl_friendly_strcmp(const char* ptr1, const char* ptr2)
459 __attribute__((always_inline));
460
461 static inline int CPL_afl_friendly_strcmp(const char* ptr1, const char* ptr2)
462 {
463 const unsigned char* usptr1 = (const unsigned char*)ptr1;
464 const unsigned char* usptr2 = (const unsigned char*)ptr2;
465 while( 1 )
466 {
467 unsigned char ch1 = *(usptr1++);
468 unsigned char ch2 = *(usptr2++);
469 if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2;
470 }
471 }
472
473 static inline int CPL_afl_friendly_strncmp(const char* ptr1, const char* ptr2, size_t len)
474 __attribute__((always_inline));
475
476 static inline int CPL_afl_friendly_strncmp(const char* ptr1, const char* ptr2, size_t len)
477 {
478 const unsigned char* usptr1 = (const unsigned char*)ptr1;
479 const unsigned char* usptr2 = (const unsigned char*)ptr2;
480 while( len -- )
481 {
482 unsigned char ch1 = *(usptr1++);
483 unsigned char ch2 = *(usptr2++);
484 if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2;
485 }
486 return 0;
487 }
488
489 static inline int CPL_afl_friendly_strcasecmp(const char* ptr1, const char* ptr2)
490 __attribute__((always_inline));
491
492 static inline int CPL_afl_friendly_strcasecmp(const char* ptr1, const char* ptr2)
493 {
494 const unsigned char* usptr1 = (const unsigned char*)ptr1;
495 const unsigned char* usptr2 = (const unsigned char*)ptr2;
496 while( 1 )
497 {
498 unsigned char ch1 = *(usptr1++);
499 unsigned char ch2 = *(usptr2++);
500 ch1 = (unsigned char)toupper(ch1);
501 ch2 = (unsigned char)toupper(ch2);
502 if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2;
503 }
504 }
505
506 static inline int CPL_afl_friendly_strncasecmp(const char* ptr1, const char* ptr2, size_t len)
507 __attribute__((always_inline));
508
509 static inline int CPL_afl_friendly_strncasecmp(const char* ptr1, const char* ptr2, size_t len)
510 {
511 const unsigned char* usptr1 = (const unsigned char*)ptr1;
512 const unsigned char* usptr2 = (const unsigned char*)ptr2;
513 while( len-- )
514 {
515 unsigned char ch1 = *(usptr1++);
516 unsigned char ch2 = *(usptr2++);
517 ch1 = (unsigned char)toupper(ch1);
518 ch2 = (unsigned char)toupper(ch2);
519 if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2;
520 }
521 return 0;
522 }
523
524 static inline char* CPL_afl_friendly_strstr(const char* haystack, const char* needle)
525 __attribute__((always_inline));
526
527 static inline char* CPL_afl_friendly_strstr(const char* haystack, const char* needle)
528 {
529 const char* ptr_haystack = haystack;
530 while( 1 )
531 {
532 const char* ptr_haystack2 = ptr_haystack;
533 const char* ptr_needle = needle;
534 while( 1 )
535 {
536 char ch1 = *(ptr_haystack2++);
537 char ch2 = *(ptr_needle++);
538 if( ch2 == 0 )
539 return (char*)ptr_haystack;
540 if( ch1 != ch2 )
541 break;
542 }
543 if( *ptr_haystack == 0 )
544 return NULL;
545 ptr_haystack ++;
546 }
547 }
548
549 #undef strcmp
550 #undef strncmp
551 #define memcmp CPL_afl_friendly_memcmp
552 #define strcmp CPL_afl_friendly_strcmp
553 #define strncmp CPL_afl_friendly_strncmp
554 #define strcasecmp CPL_afl_friendly_strcasecmp
555 #define strncasecmp CPL_afl_friendly_strncasecmp
556 #define strstr CPL_afl_friendly_strstr
557
558 #endif /* defined(AFL_FRIENDLY) && defined(__GNUC__) */
559
560 # if defined(WIN32)
561 # define STRCASECMP(a,b) (stricmp(a,b))
562 # define STRNCASECMP(a,b,n) (strnicmp(a,b,n))
563 # else
564
565 # define STRCASECMP(a,b) (strcasecmp(a,b))
566
567 # define STRNCASECMP(a,b,n) (strncasecmp(a,b,n))
568 # endif
569
570 # define EQUALN(a,b,n) (STRNCASECMP(a,b,n)==0)
571
572 # define EQUAL(a,b) (STRCASECMP(a,b)==0)
573 #endif
574
575 /*---------------------------------------------------------------------
576 * Does a string "a" start with string "b". Search is case-sensitive or,
577 * with CI, it is a case-insensitive comparison.
578 *--------------------------------------------------------------------- */
579 #ifndef STARTS_WITH_CI
580
581 #define STARTS_WITH(a,b) (strncmp(a,b,strlen(b)) == 0)
582
583 #define STARTS_WITH_CI(a,b) EQUALN(a,b,strlen(b))
584 #endif
585
587 #ifndef CPL_THREADLOCAL
588 # define CPL_THREADLOCAL
589 #endif
590
592 /* -------------------------------------------------------------------- */
593 /* Handle isnan() and isinf(). Note that isinf() and isnan() */
594 /* are supposed to be macros according to C99, defined in math.h */
595 /* Some systems (i.e. Tru64) don't have isinf() at all, so if */
596 /* the macro is not defined we just assume nothing is infinite. */
597 /* This may mean we have no real CPLIsInf() on systems with isinf()*/
598 /* function but no corresponding macro, but I can live with */
599 /* that since it isn't that important a test. */
600 /* -------------------------------------------------------------------- */
601 #ifdef _MSC_VER
602 # include <float.h>
603 # define CPLIsNan(x) _isnan(x)
604 # define CPLIsInf(x) (!_isnan(x) && !_finite(x))
605 # define CPLIsFinite(x) _finite(x)
606 #elif defined(__GNUC__) && ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) )
607 /* When including <cmath> in C++11 the isnan() macro is undefined, so that */
608 /* std::isnan() can work (#6489). This is a GCC specific workaround for now. */
609 # define CPLIsNan(x) __builtin_isnan(x)
610 # define CPLIsInf(x) __builtin_isinf(x)
611 # define CPLIsFinite(x) __builtin_isfinite(x)
612 #elif defined(__cplusplus) && defined(HAVE_STD_IS_NAN) && HAVE_STD_IS_NAN
613 extern "C++" {
614 #ifndef DOXYGEN_SKIP
615 #include <cmath>
616 #endif
617 static inline int CPLIsNan(float f) { return std::isnan(f); }
618 static inline int CPLIsNan(double f) { return std::isnan(f); }
619 static inline int CPLIsInf(float f) { return std::isinf(f); }
620 static inline int CPLIsInf(double f) { return std::isinf(f); }
621 static inline int CPLIsFinite(float f) { return std::isfinite(f); }
622 static inline int CPLIsFinite(double f) { return std::isfinite(f); }
623 }
624 #else
625
626 #if defined(__cplusplus) && defined(__GNUC__) && defined(__linux) && !defined(__ANDROID__) && !defined(CPL_SUPRESS_CPLUSPLUS)
627 /* so to not get warning about conversion from double to float with */
628 /* gcc -Wfloat-conversion when using isnan()/isinf() macros */
629 extern "C++" {
630 static inline int CPLIsNan(float f) { return __isnanf(f); }
631 static inline int CPLIsNan(double f) { return __isnan(f); }
632 static inline int CPLIsInf(float f) { return __isinff(f); }
633 static inline int CPLIsInf(double f) { return __isinf(f); }
634 static inline int CPLIsFinite(float f) { return !__isnanf(f) && !__isinff(f); }
635 static inline int CPLIsFinite(double f) { return !__isnan(f) && !__isinf(f); }
636 }
637 #else
638 # define CPLIsNan(x) isnan(x)
639 # if defined(isinf) || defined(__FreeBSD__)
640
641 # define CPLIsInf(x) isinf(x)
642
643 # define CPLIsFinite(x) (!isnan(x) && !isinf(x))
644 # elif defined(__sun__)
645 # include <ieeefp.h>
646 # define CPLIsInf(x) (!finite(x) && !isnan(x))
647 # define CPLIsFinite(x) finite(x)
648 # else
649 # define CPLIsInf(x) (0)
650 # define CPLIsFinite(x) (!isnan(x))
651 # endif
652 #endif
653 #endif
654
656 /*---------------------------------------------------------------------
657 * CPL_LSB and CPL_MSB
658 * Only one of these 2 macros should be defined and specifies the byte
659 * ordering for the current platform.
660 * This should be defined in the Makefile, but if it is not then
661 * the default is CPL_LSB (Intel ordering, LSB first).
662 *--------------------------------------------------------------------*/
663 #if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB)
664 # define CPL_MSB
665 #endif
666
667 #if ! ( defined(CPL_LSB) || defined(CPL_MSB) )
668 #define CPL_LSB
669 #endif
670
671 #if defined(CPL_LSB)
672 # define CPL_IS_LSB 1
673 #else
674 # define CPL_IS_LSB 0
675 #endif
676
678 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
679
681 extern "C++" {
682
683 template <bool b> struct CPLStaticAssert {};
684 template<> struct CPLStaticAssert<true>
685 {
686 static void my_function() {}
687 };
688
689 } /* extern "C++" */
690
691 #define CPL_STATIC_ASSERT(x) CPLStaticAssert<x>::my_function()
692 #define CPL_STATIC_ASSERT_IF_AVAILABLE(x) CPL_STATIC_ASSERT(x)
693
694 #else /* __cplusplus */
695
696 #define CPL_STATIC_ASSERT_IF_AVAILABLE(x)
697
698 #endif /* __cplusplus */
699
701 /*---------------------------------------------------------------------
702 * Little endian <==> big endian byte swap macros.
703 *--------------------------------------------------------------------*/
704
706 #define CPL_SWAP16(x) CPL_STATIC_CAST(GUInt16, (CPL_STATIC_CAST(GUInt16, x) << 8) | (CPL_STATIC_CAST(GUInt16, x) >> 8) )
707
708 #if defined(HAVE_GCC_BSWAP) && (defined(__i386__) || defined(__x86_64__))
709 /* Could potentially be extended to other architectures but must be checked */
710 /* that the intrinsic is indeed efficient */
711 /* GCC (at least 4.6 or above) need that include */
712 #include <x86intrin.h>
714 #define CPL_SWAP32(x) CPL_STATIC_CAST(GUInt32, __builtin_bswap32(CPL_STATIC_CAST(GUInt32, x)))
715
716 #define CPL_SWAP64(x) CPL_STATIC_CAST(GUInt64, __builtin_bswap64(CPL_STATIC_CAST(GUInt64, x)))
717 #elif defined(_MSC_VER)
718 #define CPL_SWAP32(x) CPL_STATIC_CAST(GUInt32, _byteswap_ulong(CPL_STATIC_CAST(GUInt32, x)))
719 #define CPL_SWAP64(x) CPL_STATIC_CAST(GUInt64, _byteswap_uint64(CPL_STATIC_CAST(GUInt64, x)))
720 #else
721
722 #define CPL_SWAP32(x) \
723 CPL_STATIC_CAST(GUInt32, \
724 ((CPL_STATIC_CAST(GUInt32, x) & 0x000000ffU) << 24) | \
725 ((CPL_STATIC_CAST(GUInt32, x) & 0x0000ff00U) << 8) | \
726 ((CPL_STATIC_CAST(GUInt32, x) & 0x00ff0000U) >> 8) | \
727 ((CPL_STATIC_CAST(GUInt32, x) & 0xff000000U) >> 24) )
728
730 #define CPL_SWAP64(x) \
731 ((CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, x))) << 32) | \
732 (CPL_STATIC_CAST(GUInt64, CPL_SWAP32(CPL_STATIC_CAST(GUInt32, CPL_STATIC_CAST(GUInt64, x) >> 32)))))
733
734 #endif
735
737 #define CPL_SWAP16PTR(x) \
738 { \
739 GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
740 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2); \
741 \
742 byTemp = _pabyDataT[0]; \
743 _pabyDataT[0] = _pabyDataT[1]; \
744 _pabyDataT[1] = byTemp; \
745 }
746
747 #if defined(MAKE_SANITIZE_HAPPY) || !(defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64))
748
750 #define CPL_SWAP32PTR(x) \
751 { \
752 GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
753 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \
754 \
755 byTemp = _pabyDataT[0]; \
756 _pabyDataT[0] = _pabyDataT[3]; \
757 _pabyDataT[3] = byTemp; \
758 byTemp = _pabyDataT[1]; \
759 _pabyDataT[1] = _pabyDataT[2]; \
760 _pabyDataT[2] = byTemp; \
761 }
762
764 #define CPL_SWAP64PTR(x) \
765 { \
766 GByte byTemp, *_pabyDataT = CPL_REINTERPRET_CAST(GByte*, x); \
767 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \
768 \
769 byTemp = _pabyDataT[0]; \
770 _pabyDataT[0] = _pabyDataT[7]; \
771 _pabyDataT[7] = byTemp; \
772 byTemp = _pabyDataT[1]; \
773 _pabyDataT[1] = _pabyDataT[6]; \
774 _pabyDataT[6] = byTemp; \
775 byTemp = _pabyDataT[2]; \
776 _pabyDataT[2] = _pabyDataT[5]; \
777 _pabyDataT[5] = byTemp; \
778 byTemp = _pabyDataT[3]; \
779 _pabyDataT[3] = _pabyDataT[4]; \
780 _pabyDataT[4] = byTemp; \
781 }
782
783 #else
784
786 #define CPL_SWAP32PTR(x) \
787 { \
788 GUInt32 _n32; \
789 void* _lx = x; \
790 memcpy(&_n32, _lx, 4); \
791 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \
792 _n32 = CPL_SWAP32(_n32); \
793 memcpy(_lx, &_n32, 4); \
794 }
795
797 #define CPL_SWAP64PTR(x) \
798 { \
799 GUInt64 _n64; \
800 void* _lx = x; \
801 memcpy(&_n64, _lx, 8); \
802 CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \
803 _n64 = CPL_SWAP64(_n64); \
804 memcpy(_lx, &_n64, 8); \
805 }
806
807 #endif
808
810 #define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
811
812 #ifdef CPL_MSB
813 # define CPL_MSBWORD16(x) (x)
814 # define CPL_LSBWORD16(x) CPL_SWAP16(x)
815 # define CPL_MSBWORD32(x) (x)
816 # define CPL_LSBWORD32(x) CPL_SWAP32(x)
817 # define CPL_MSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
818 # define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
819 # define CPL_MSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
820 # define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
821 # define CPL_MSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
822 # define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
823 #else
824
825 # define CPL_LSBWORD16(x) (x)
826
827 # define CPL_MSBWORD16(x) CPL_SWAP16(x)
828
829 # define CPL_LSBWORD32(x) (x)
830
831 # define CPL_MSBWORD32(x) CPL_SWAP32(x)
832
833 # define CPL_LSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2)
834
835 # define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
836
837 # define CPL_LSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4)
838
839 # define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
840
841 # define CPL_LSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8)
842
843 # define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
844 #endif
845
849 #define CPL_LSBINT16PTR(x) ((*CPL_REINTERPRET_CAST(const GByte*, x)) | (*((CPL_REINTERPRET_CAST(const GByte*, x))+1) << 8))
850
854 #define CPL_LSBINT32PTR(x) ((*CPL_REINTERPRET_CAST(const GByte*, x)) | (*((CPL_REINTERPRET_CAST(const GByte*, x))+1) << 8) | \
855 (*((CPL_REINTERPRET_CAST(const GByte*, x))+2) << 16) | (*((CPL_REINTERPRET_CAST(const GByte*, x))+3) << 24))
856
858 #define CPL_LSBSINT16PTR(x) CPL_STATIC_CAST(GInt16,CPL_LSBINT16PTR(x))
859
861 #define CPL_LSBUINT16PTR(x) CPL_STATIC_CAST(GUInt16, CPL_LSBINT16PTR(x))
862
864 #define CPL_LSBSINT32PTR(x) CPL_STATIC_CAST(GInt32, CPL_LSBINT32PTR(x))
865
867 #define CPL_LSBUINT32PTR(x) CPL_STATIC_CAST(GUInt32, CPL_LSBINT32PTR(x))
868
870 /* Utility macro to explicitly mark intentionally unreferenced parameters. */
871 #ifndef UNREFERENCED_PARAM
872 # ifdef UNREFERENCED_PARAMETER /* May be defined by Windows API */
873 # define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param)
874 # else
875 # define UNREFERENCED_PARAM(param) ((void)param)
876 # endif /* UNREFERENCED_PARAMETER */
877 #endif /* UNREFERENCED_PARAM */
878
880 /***********************************************************************
881 * Define CPL_CVSID() macro. It can be disabled during a build by
882 * defining DISABLE_CVSID in the compiler options.
883 *
884 * The cvsid_aw() function is just there to prevent reports of cpl_cvsid()
885 * being unused.
886 */
887
889 #ifndef DISABLE_CVSID
890 #if defined(__GNUC__) && __GNUC__ >= 4
891 # define CPL_CVSID(string) static const char cpl_cvsid[] __attribute__((used)) = string;
892 #else
893 # define CPL_CVSID(string) static const char cpl_cvsid[] = string; \
894 static const char *cvsid_aw() { return( cvsid_aw() ? NULL : cpl_cvsid ); }
895 #endif
896 #else
897 # define CPL_CVSID(string)
898 #endif
899
901 /* We exclude mingw64 4.6 which seems to be broken regarding this */
902 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) && !(defined(__MINGW64__) && __GNUC__ == 4 && __GNUC_MINOR__ == 6)
903
904 # define CPL_NULL_TERMINATED __attribute__((__sentinel__))
905 #else
906
907 # define CPL_NULL_TERMINATED
908 #endif
909
910 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
911
912 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
913
914 #define CPL_SCAN_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
915 #else
916
917 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx )
918
919 #define CPL_SCAN_FUNC_FORMAT( format_idx, arg_idx )
920 #endif
921
922 #if defined(_MSC_VER) && (defined(GDAL_COMPILATION) || defined(CPL_ENABLE_MSVC_ANNOTATIONS))
923 #include <sal.h>
926 # define CPL_FORMAT_STRING(arg) _Printf_format_string_ arg
927
929 # define CPL_SCANF_FORMAT_STRING(arg) _Scanf_format_string_ arg
930 #else
931
932 # define CPL_FORMAT_STRING(arg) arg
933
934 # define CPL_SCANF_FORMAT_STRING(arg) arg
935 #endif /* defined(_MSC_VER) && defined(GDAL_COMPILATION) */
936
937 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
938
939 #define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
940 #else
941
942 #define CPL_WARN_UNUSED_RESULT
943 #endif
944
945 #if defined(__GNUC__) && __GNUC__ >= 4
946
947 # define CPL_UNUSED __attribute((__unused__))
948 #else
949 /* TODO: add cases for other compilers */
951 # define CPL_UNUSED
952 #endif
953
954 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
955
956 #define CPL_NO_RETURN __attribute__((noreturn))
957 #else
958
959 #define CPL_NO_RETURN
960 #endif
961
963 /* Clang __has_attribute */
964 #ifndef __has_attribute
965 #define __has_attribute(x) 0 // Compatibility with non-clang compilers.
966 #endif
967
970 #if ((defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) || __has_attribute(returns_nonnull)) && !defined(DOXYGEN_SKIP) && !defined(__INTEL_COMPILER)
971
972 # define CPL_RETURNS_NONNULL __attribute__((returns_nonnull))
973 #else
974
975 # define CPL_RETURNS_NONNULL
976 #endif
977
978 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
979
980 #define CPL_RESTRICT __restrict__
981 #else
982
983 #define CPL_RESTRICT
984 #endif
985
986 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
987
990 # define CPL_OVERRIDE override
991
993 # define CPL_FINAL final
994
996 # define CPL_NON_FINAL
997
1003 # define CPL_DISALLOW_COPY_ASSIGN(ClassName) \
1004 ClassName( const ClassName & ) = delete; \
1005 ClassName &operator=( const ClassName & ) = delete;
1006
1007 #endif /* __cplusplus */
1008
1009 #if !defined(DOXYGEN_SKIP)
1010 #if defined(__has_extension)
1011 #if __has_extension(attribute_deprecated_with_message)
1012 /* Clang extension */
1013 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated(x)))
1014 #else
1015 #define CPL_WARN_DEPRECATED(x)
1016 #endif
1017 #elif defined(__GNUC__)
1018 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated))
1019 #else
1020 #define CPL_WARN_DEPRECATED(x)
1021 #endif
1022 #endif
1023
1024 #if !defined(_MSC_VER) && !defined(__APPLE__) && !defined(_FORTIFY_SOURCE)
1025 CPL_C_START
1026 # if defined(GDAL_COMPILATION) && defined(WARN_STANDARD_PRINTF)
1027 int vsnprintf(char *str, size_t size, const char* fmt, va_list args)
1028 CPL_WARN_DEPRECATED("Use CPLvsnprintf() instead");
1029 int snprintf(char *str, size_t size, const char* fmt, ...)
1030 CPL_PRINT_FUNC_FORMAT(3,4)
1031 CPL_WARN_DEPRECATED("Use CPLsnprintf() instead");
1032 int sprintf(char *str, const char* fmt, ...)
1033 CPL_PRINT_FUNC_FORMAT(2, 3)
1034 CPL_WARN_DEPRECATED("Use CPLsnprintf() instead");
1035 # elif defined(GDAL_COMPILATION) && !defined(DONT_DEPRECATE_SPRINTF)
1036 int sprintf(char *str, const char* fmt, ...)
1037 CPL_PRINT_FUNC_FORMAT(2, 3)
1038 CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
1039 # endif /* defined(GDAL_COMPILATION) && defined(WARN_STANDARD_PRINTF) */
1040 CPL_C_END
1041 #endif /* !defined(_MSC_VER) && !defined(__APPLE__) */
1042
1043 #if defined(MAKE_SANITIZE_HAPPY) || !(defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64))
1044
1045 #define CPL_CPU_REQUIRES_ALIGNED_ACCESS
1046
1047 #endif
1048
1049 #if defined(__cplusplus)
1050
1051 #define CPL_ARRAYSIZE(array) \
1052 ((sizeof(array) / sizeof(*(array))) / \
1053 static_cast<size_t>(!(sizeof(array) % sizeof(*(array)))))
1054
1055 extern "C++" {
1056 template<class T> static void CPL_IGNORE_RET_VAL(T) {}
1057 inline static bool CPL_TO_BOOL(int x) { return x != 0; }
1058 } /* extern "C++" */
1059
1060 #endif /* __cplusplus */
1061
1062 #if (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || (defined(__clang__) && __clang_major__ >= 3)) && !defined(_MSC_VER))
1063 #define HAVE_GCC_DIAGNOSTIC_PUSH
1064 #endif
1065
1066 #if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) && !defined(_MSC_VER))
1067 #define HAVE_GCC_SYSTEM_HEADER
1068 #endif
1069
1070 #if ((defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))) || __GNUC__ >= 7)
1071
1072 # define CPL_FALLTHROUGH [[clang::fallthrough]];
1073 #else
1074
1075 # define CPL_FALLTHROUGH
1076 #endif
1077
1079 // Define DEBUG_BOOL to compile in "MSVC mode", ie error out when
1080 // a integer is assigned to a bool
1081 // WARNING: use only at compilation time, since it is know to not work
1082 // at runtime for unknown reasons (crash in MongoDB driver for example)
1083 #if defined(__cplusplus) && defined(DEBUG_BOOL) && !defined(DO_NOT_USE_DEBUG_BOOL) && !defined(CPL_SUPRESS_CPLUSPLUS)
1084 extern "C++" {
1085 class MSVCPedanticBool
1086 {
1087
1088 friend bool operator== (const bool& one, const MSVCPedanticBool& other);
1089 friend bool operator!= (const bool& one, const MSVCPedanticBool& other);
1090
1091 bool b;
1092 MSVCPedanticBool(int bIn);
1093
1094 public:
1095 /* b not initialized on purpose in default ctor to flag use. */
1096 /* cppcheck-suppress uninitMemberVar */
1097 MSVCPedanticBool() {}
1098 MSVCPedanticBool(bool bIn) : b(bIn) {}
1099 MSVCPedanticBool(const MSVCPedanticBool& other) : b(other.b) {}
1100
1101 MSVCPedanticBool& operator= (const MSVCPedanticBool& other) { b = other.b; return *this; }
1102 MSVCPedanticBool& operator&= (const MSVCPedanticBool& other) { b &= other.b; return *this; }
1103 MSVCPedanticBool& operator|= (const MSVCPedanticBool& other) { b |= other.b; return *this; }
1104
1105 bool operator== (const bool& other) const { return b == other; }
1106 bool operator!= (const bool& other) const { return b != other; }
1107 bool operator< (const bool& other) const { return b < other; }
1108 bool operator== (const MSVCPedanticBool& other) const { return b == other.b; }
1109 bool operator!= (const MSVCPedanticBool& other) const { return b != other.b; }
1110 bool operator< (const MSVCPedanticBool& other) const { return b < other.b; }
1111
1112 bool operator! () const { return !b; }
1113 operator bool() const { return b; }
1114 operator int() const { return b; }
1115 operator GIntBig() const { return b; }
1116 };
1117
1118 inline bool operator== (const bool& one, const MSVCPedanticBool& other) { return one == other.b; }
1119 inline bool operator!= (const bool& one, const MSVCPedanticBool& other) { return one != other.b; }
1120
1121 /* We must include all C++ stuff before to avoid issues with templates that use bool */
1122 #include <vector>
1123 #include <map>
1124 #include <set>
1125 #include <string>
1126 #include <cstddef>
1127 #include <limits>
1128 #include <sstream>
1129 #include <fstream>
1130 #include <algorithm>
1131 #include <functional>
1132 #include <memory>
1133 #include <queue>
1134 #include <mutex>
1135 #include <unordered_map>
1136 #include <thread>
1137 #include <unordered_set>
1138 #include <complex>
1139 #include <iomanip>
1140
1141 } /* extern C++ */
1142
1143 #undef FALSE
1144 #define FALSE false
1145 #undef TRUE
1146 #define TRUE true
1147
1148 /* In the very few cases we really need a "simple" type, fallback to bool */
1149 #define EMULATED_BOOL int
1150
1151 /* Use our class instead of bool */
1152 #define bool MSVCPedanticBool
1153
1154 /* "volatile bool" with the below substitution doesn't really work. */
1155 /* Just for the sake of the debug, we don't really need volatile */
1156 #define VOLATILE_BOOL bool
1157
1158 #else /* defined(__cplusplus) && defined(DEBUG_BOOL) */
1159
1160 #ifndef FALSE
1161 # define FALSE 0
1162 #endif
1163
1164 #ifndef TRUE
1165 # define TRUE 1
1166 #endif
1167
1168 #define EMULATED_BOOL bool
1169 #define VOLATILE_BOOL volatile bool
1170
1171 #endif /* defined(__cplusplus) && defined(DEBUG_BOOL) */
1172
1173 #if __clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 8)
1174 #define CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow")))
1175 #else
1176 #define CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW
1177 #endif
1178
1179 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && defined(GDAL_COMPILATION)
1180 extern "C++" {
1181 template<class C, class A, class B>
1182 CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW
1183 inline C CPLUnsanitizedAdd(A a, B b)
1184 {
1185 return a + b;
1186 }
1187 }
1188 #endif
1189
1193 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
1194 #define CPL_NULLPTR nullptr
1195 #else
1196 #define CPL_NULLPTR NULL
1197 #endif
1198
1200 /* This typedef is for C functions that take char** as argument, but */
1201 /* with the semantics of a const list. In C, char** is not implicitly cast to */
1202 /* const char* const*, contrary to C++. So when seen for C++, it is OK */
1203 /* to expose the prototyes as const char* const*, but for C we keep the */
1204 /* historical definition to avoid warnings. */
1205 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) && !defined(DOXYGEN_SKIP)
1206
1208 typedef const char* const* CSLConstList;
1209 #else
1210
1212 typedef char** CSLConstList;
1213 #endif
1214
1215 #endif /* ndef CPL_BASE_H_INCLUDED */
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
GBool
int GBool
Type for boolean values (alias to int)
Definition: cpl_port.h:223
GInt32
int GInt32
Int32 type.
Definition: cpl_port.h:205
GUInt32
unsigned int GUInt32
Unsigned int32 type.
Definition: cpl_port.h:207
GInt16
short GInt16
Int16 type.
Definition: cpl_port.h:211
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
CPL_PRINT_FUNC_FORMAT
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:917
GUInt64
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:269
GPtrDiff_t
GIntBig GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:286
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1212
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:251
GUInt16
unsigned short GUInt16
Unsigned int16 type.
Definition: cpl_port.h:213
CPLsnprintf
int CPLsnprintf(char *str, size_t size, const char *fmt,...)
snprintf() wrapper that is not sensitive to LC_NUMERIC settings.
Definition: cpl_string.cpp:1337
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
GInt64
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:267