Skip to content

Commit

Permalink
Merge pull request #6645 from Yay295/int_def
Browse files Browse the repository at this point in the history
Better C integer definitions
  • Loading branch information
radarhere committed Jun 24, 2023
2 parents 6c464b8 + 36487fe commit 0d54cf5
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/libImaging/ImPlatform.h
Expand Up @@ -25,7 +25,7 @@
#endif
#endif

#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
Expand All @@ -37,15 +37,33 @@
#undef WIN32
#endif

#else
#else /* not WIN */
/* For System that are not Windows, we'll need to define these. */
/* We have to define them instead of using typedef because the JPEG lib also
defines their own types with the same names, so we need to be able to undef
ours before including the JPEG code. */

#if __STDC_VERSION__ >= 199901L /* C99+ */

#include <stdint.h>

#define INT8 int8_t
#define UINT8 uint8_t
#define INT16 int16_t
#define UINT16 uint16_t
#define INT32 int32_t
#define UINT32 uint32_t

#else /* < C99 */

#define INT8 signed char

#if SIZEOF_SHORT == 2
#define INT16 short
#elif SIZEOF_INT == 2
#define INT16 int
#else
#define INT16 short /* most things works just fine anyway... */
#error Cannot find required 16-bit integer type
#endif

#if SIZEOF_SHORT == 4
Expand All @@ -58,13 +76,13 @@
#error Cannot find required 32-bit integer type
#endif

#define INT8 signed char
#define UINT8 unsigned char

#define UINT16 unsigned INT16
#define UINT32 unsigned INT32

#endif
#endif /* < C99 */

#endif /* not WIN */

/* assume IEEE; tweak if necessary (patches are welcome) */
#define FLOAT16 UINT16
Expand Down

0 comments on commit 0d54cf5

Please sign in to comment.