Add support for using liblzma headers in MSVC, which has no

stdint.h or inttypes.h.
This commit is contained in:
Lasse Collin 2009-01-31 09:55:05 +02:00
parent b2172cf823
commit 4ab7601091
1 changed files with 46 additions and 24 deletions

View File

@ -73,16 +73,29 @@
*/ */
# if !defined(UINT32_C) || !defined(UINT64_C) \ # if !defined(UINT32_C) || !defined(UINT64_C) \
|| !defined(UINT32_MAX) || !defined(UINT64_MAX) || !defined(UINT32_MAX) || !defined(UINT64_MAX)
/*
* MSVC has no C99 support, and thus it cannot be used to
* compile liblzma. The liblzma API has to still be usable
* from MSVC, so we need to define the required standard
* integer types here.
*/
#if defined(_WIN32) && defined(_MSC_VER)
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
# else
/* Use the standard inttypes.h. */
# ifdef __cplusplus # ifdef __cplusplus
/* /*
* C99 sections 7.18.2 and 7.18.4 specify that in C++ * C99 sections 7.18.2 and 7.18.4 specify that
* implementations define the limit and constant * in C++ implementations define the limit
* macros only if specifically requested. Note that * and constant macros only if specifically
* if you want the format macros (PRIu64 etc.) too, * requested. Note that if you want the
* you need to define __STDC_FORMAT_MACROS before * format macros (PRIu64 etc.) too, you need
* including lzma.h, since re-including inttypes.h * to define __STDC_FORMAT_MACROS before
* with __STDC_FORMAT_MACROS defined doesn't * including lzma.h, since re-including
* necessarily work. * inttypes.h with __STDC_FORMAT_MACROS
* defined doesn't necessarily work.
*/ */
# ifndef __STDC_LIMIT_MACROS # ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS 1 # define __STDC_LIMIT_MACROS 1
@ -93,6 +106,7 @@
# endif # endif
# include <inttypes.h> # include <inttypes.h>
# endif
/* /*
* Some old systems have only the typedefs in inttypes.h, and * Some old systems have only the typedefs in inttypes.h, and
@ -103,10 +117,17 @@
* before including lzma.h. * before including lzma.h.
*/ */
# ifndef UINT32_C # ifndef UINT32_C
# if defined(_WIN32) && defined(_MSC_VER)
# define UINT32_C(n) n ## UI32
# else
# define UINT32_C(n) n ## U # define UINT32_C(n) n ## U
# endif # endif
# endif
# ifndef UINT64_C # ifndef UINT64_C
# if defined(_WIN32) && defined(_MSC_VER)
# define UINT64_C(n) n ## UI64
# else
/* Get ULONG_MAX. */ /* Get ULONG_MAX. */
# include <limits.h> # include <limits.h>
# if ULONG_MAX == 4294967295UL # if ULONG_MAX == 4294967295UL
@ -115,6 +136,7 @@
# define UINT64_C(n) n ## UL # define UINT64_C(n) n ## UL
# endif # endif
# endif # endif
# endif
# ifndef UINT32_MAX # ifndef UINT32_MAX
# define UINT32_MAX (UINT32_C(4294967295)) # define UINT32_MAX (UINT32_C(4294967295))