diff options
Diffstat (limited to 'pcap/pcap-inttypes.h')
-rw-r--r-- | pcap/pcap-inttypes.h | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/pcap/pcap-inttypes.h b/pcap/pcap-inttypes.h index 1cfa0bfc..8c7b4f65 100644 --- a/pcap/pcap-inttypes.h +++ b/pcap/pcap-inttypes.h @@ -32,8 +32,8 @@ #define pcap_pcap_inttypes_h /* - * If we're compiling with Visual Studio, make sure we have at least - * VS 2015 or later, so we have sufficient C99 support. + * If we're compiling with Visual Studio, make sure the C99 integer + * types are defined, by hook or by crook. * * XXX - verify that we have at least C99 support on UN*Xes? * @@ -42,39 +42,60 @@ */ #if defined(_MSC_VER) /* - * Compiler is MSVC. Make sure we have VS 2015 or later. + * Compiler is MSVC. */ - #if _MSC_VER < 1900 - #error "Building libpcap requires VS 2015 or later" + #if _MSC_VER >= 1800 + /* + * VS 2013 or newer; we have <inttypes.h>. + */ + #include <inttypes.h> + #else + /* + * Earlier VS; we have to define this stuff ourselves. + * We don't support building libpcap with earlier versions of VS, + * but SDKs for Npcap have to support building applications using + * earlier versions of VS, so we work around this by defining + * those types ourselves, as some files use them. + */ + typedef unsigned char uint8_t; + typedef signed char int8_t; + typedef unsigned short uint16_t; + typedef signed short int16_t; + typedef unsigned int uint32_t; + typedef signed int int32_t; + #ifdef _MSC_EXTENSIONS + typedef unsigned _int64 uint64_t; + typedef _int64 int64_t; + #else /* _MSC_EXTENSIONS */ + typedef unsigned long long uint64_t; + typedef long long int64_t; + #endif #endif -#endif - -/* - * Include <inttypes.h> to get the integer types and PRi[doux]64 values - * defined. - * - * If the compiler is MSVC, we require VS 2015 or newer, so we - * have <inttypes.h> - and support for %zu in the formatted - * printing functions. - * - * If the compiler is MinGW, we assume we have <inttypes.h> - and - * support for %zu in the formatted printing functions. - * - * If the target is UN*X, we assume we have a C99-or-later development - * environment, and thus have <inttypes.h> - and support for %zu in - * the formatted printing functions. - * - * If the target is MS-DOS, we assume we have <inttypes.h> - and support - * for %zu in the formatted printing functions. - * - * I.e., assume we have <inttypes.h> and that it suffices. - */ +#else /* defined(_MSC_VER) */ + /* + * Not Visual Studio. + * Include <inttypes.h> to get the integer types and PRi[doux]64 values + * defined. + * + * If the compiler is MinGW, we assume we have <inttypes.h> - and + * support for %zu in the formatted printing functions. + * + * If the target is UN*X, we assume we have a C99-or-later development + * environment, and thus have <inttypes.h> - and support for %zu in + * the formatted printing functions. + * + * If the target is MS-DOS, we assume we have <inttypes.h> - and support + * for %zu in the formatted printing functions. + * + * I.e., assume we have <inttypes.h> and that it suffices. + */ -/* - * XXX - somehow make sure we have enough C99 support with other - * compilers and support libraries? - */ + /* + * XXX - somehow make sure we have enough C99 support with other + * compilers and support libraries? + */ -#include <inttypes.h> + #include <inttypes.h> +#endif /* defined(_MSC_VER) */ #endif /* pcap/pcap-inttypes.h */ |