Mercurial > hg > dmlib
comparison src/dmlib.h @ 2542:b544a8e32a35
Perhaps improve type definitions for MinGW v8+
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 18 Oct 2021 01:06:14 +0300 |
parents | c6ee41fd98dd |
children | c58cd7797aff |
comparison
equal
deleted
inserted
replaced
2541:671f41166527 | 2542:b544a8e32a35 |
---|---|
4 * Programmed and designed by Matti 'ccr' Hamalainen | 4 * Programmed and designed by Matti 'ccr' Hamalainen |
5 * (C) Copyright 2011-2021 Tecnic Software productions (TNSP) | 5 * (C) Copyright 2011-2021 Tecnic Software productions (TNSP) |
6 */ | 6 */ |
7 #ifndef DMLIB_H | 7 #ifndef DMLIB_H |
8 #define DMLIB_H | 8 #define DMLIB_H |
9 | |
10 // Meh, this is a hack due to the crap non-portability of 64bit | |
11 // printf PRI* type specifiers/modifiers | |
12 #if !defined(DM_USE_BONK_TYPES) && (defined(__MINGW32__) || defined(__MINGW64__)) | |
13 # define __USE_MINGW_ANSI_STDIO 1 | |
14 #endif | |
9 | 15 |
10 #include <SDL_config.h> | 16 #include <SDL_config.h> |
11 #include <SDL_endian.h> | 17 #include <SDL_endian.h> |
12 #include <SDL_types.h> | 18 #include <SDL_types.h> |
13 #include <SDL_mutex.h> | 19 #include <SDL_mutex.h> |
62 # endif | 68 # endif |
63 #endif | 69 #endif |
64 | 70 |
65 | 71 |
66 // Kludge, as MinGW64 cross-compiler does not like certain printf() format specifiers | 72 // Kludge, as MinGW64 cross-compiler does not like certain printf() format specifiers |
67 #if defined(__MINGW64__) | 73 #if defined(__MINGW32__) || defined(__MINGW64__) |
68 # define DM_ATTR_PRINTF_FMT(xstart, xend) | 74 # define DM_ATTR_PRINTF_FMT(xstart, xend) |
69 #else | 75 #else |
70 # define DM_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend)))) | 76 # define DM_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend)))) |
71 #endif | 77 #endif |
72 | 78 |
73 | 79 |
74 // Do we have a valid arch? | 80 // Do we have a valid arch? |
75 // If so, set some printf specifiers | 81 // If so, set some printf specifiers |
76 #define DM_PRIu32 PRIu32 | |
77 #define DM_PRId32 PRId32 | |
78 #define DM_PRIx32 PRIx32 | |
79 #define DM_PRIX32 PRIX32 | |
80 | |
81 #define DM_PRIu64 PRIu64 | |
82 #define DM_PRId64 PRId64 | |
83 #define DM_PRIx64 PRIx64 | |
84 #define DM_PRIX64 PRIX64 | |
85 | |
86 #if DM_ARCH == 32 | 82 #if DM_ARCH == 32 |
83 # define DM_PRIu32 PRIu32 | |
84 # define DM_PRId32 PRId32 | |
85 # define DM_PRIx32 PRIx32 | |
86 # define DM_PRIX32 PRIX32 | |
87 # ifdef TH_USE_BONK_TYPES | |
88 # define DM_PRIu64 "lld" | |
89 # define DM_PRId64 "lld" | |
90 # define DM_PRIx64 "llx" | |
91 # define DM_PRIX64 "llX" | |
92 # define DM_PRId_OFF_T "ld" | |
93 # define DM_PRIx_OFF_T "lx" | |
94 # define DM_PRIX_OFF_T "lX" | |
95 # else | |
96 # define DM_PRIu64 PRIu64 | |
97 # define DM_PRId64 PRId64 | |
98 # define DM_PRIx64 PRIx64 | |
99 # define DM_PRIX64 PRIX64 | |
100 # define DM_PRId_OFF_T PRId32 | |
101 # define DM_PRIx_OFF_T PRIx32 | |
102 # define DM_PRIX_OFF_T PRIX32 | |
103 # endif | |
87 # define DM_PRIu_SIZE_T PRIu32 | 104 # define DM_PRIu_SIZE_T PRIu32 |
88 # define DM_PRId_SSIZE_T PRId32 | 105 # define DM_PRId_SSIZE_T PRId32 |
89 # define DM_PRIx_SIZE_T PRIx32 | 106 # define DM_PRIx_SIZE_T PRIx32 |
90 # define DM_PRIX_SIZE_T PRIX32 | 107 # define DM_PRIX_SIZE_T PRIX32 |
91 # ifdef DM_PLAT_WINDOWS | 108 |
92 # define DM_PRId_OFF_T "ld" | |
93 # define DM_PRIx_OFF_T "lx" | |
94 # define DM_PRIX_OFF_T "lX" | |
95 # else | |
96 # define DM_PRId_OFF_T PRId32 | |
97 # define DM_PRIx_OFF_T PRIx32 | |
98 # define DM_PRIX_OFF_T PRIX32 | |
99 # endif | |
100 #elif DM_ARCH == 64 | 109 #elif DM_ARCH == 64 |
101 # ifdef DM_PLAT_WINDOWS // Unsure if this is MinGW64 only thing? | 110 # define DM_PRIu64 PRIu64 |
111 # define DM_PRId64 PRId64 | |
112 # define DM_PRIx64 PRIx64 | |
113 # define DM_PRIX64 PRIX64 | |
114 # ifdef TH_USE_BONK_TYPES | |
102 # define DM_PRIu_SIZE_T "I64u" | 115 # define DM_PRIu_SIZE_T "I64u" |
103 # define DM_PRId_SSIZE_T "I64d" | 116 # define DM_PRId_SSIZE_T "I64d" |
104 # define DM_PRIx_SIZE_T "I64x" | 117 # define DM_PRIx_SIZE_T "I64x" |
105 # define DM_PRIX_SIZE_T "I64X" | 118 # define DM_PRIX_SIZE_T "I64X" |
106 # define DM_PRId_OFF_T "I64d" | 119 # define DM_PRId_OFF_T "I64d" |