summaryrefslogtreecommitdiff
path: root/netdissect-stdinc.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-08-08 20:03:00 -0700
committerGuy Harris <guy@alum.mit.edu>2019-08-08 20:03:00 -0700
commit846e943f2bb08e28ae78ca7f2e627d089f073ba1 (patch)
tree3e5aac7fdce447b26dfc058fd436aaccf7e816b5 /netdissect-stdinc.h
parent5f99fabd0bc791b8f22b172b16da9af8d5a8e761 (diff)
downloadtcpdump-846e943f2bb08e28ae78ca7f2e627d089f073ba1.tar.gz
Require VS 2015 or later for Windows builds using Visual Studio.
Forcibly fail the build if we don't have it, and just include <inttypes.h> if we do.
Diffstat (limited to 'netdissect-stdinc.h')
-rw-r--r--netdissect-stdinc.h90
1 files changed, 41 insertions, 49 deletions
diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h
index 5aef8234..c52e72a9 100644
--- a/netdissect-stdinc.h
+++ b/netdissect-stdinc.h
@@ -46,6 +46,21 @@
#include "varattrs.h"
/*
+ * XXX - verify that we have at least C99 support on UN*Xes?
+ *
+ * What about MinGW or various DOS toolchains? We're currently assuming
+ * sufficient C99 support there.
+ */
+#if defined(_MSC_VER)
+ /*
+ * Make sure we have VS 2015 or later.
+ */
+ #if _MSC_VER < 1900
+ #error "Building tcpdump requires VS 2015 or later"
+ #endif
+#endif
+
+/*
* Get the C99 types, and the PRI[doux]64 format strings, defined.
*/
#ifdef HAVE_PCAP_PCAP_INTTYPES_H
@@ -63,39 +78,25 @@
* worry about other headers including it and causing
* clashes.
*/
- #if defined(_MSC_VER)
- /*
- * Compiler is MSVC.
- */
- #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.
- */
- 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
- /*
- * We have _strtoi64(). Use that for strtoint64_t().
- */
- #define strtoint64_t _strtoi64
- #endif
+ /*
+ * 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.
+ */
+ #include <inttypes.h>
+ #if defined(_MSC_VER)
/*
* Suppress definition of intN_t in bittypes.h, which might be included
* by <pcap/pcap.h> in older versions of WinPcap.
@@ -111,6 +112,9 @@
* These may be defined by <inttypes.h>. If not, define them
* ourselves.
*
+ * XXX - given the assumptions above, will they ever *not* be
+ * defined by <inttypes.h>?
+ *
* XXX - for MSVC, we always want the _MSC_EXTENSIONS versions.
* What about other compilers? If, as the MinGW Web site says MinGW
* does, the other compilers just use Microsoft's run-time library,
@@ -148,12 +152,6 @@
#define PRIu64 "llu"
#endif
#endif
- #elif defined(__MINGW32__) || !defined(_WIN32)
- /*
- * Compiler is MinGW or target is UN*X or MS-DOS. Just use
- * <inttypes.h>.
- */
- #include <inttypes.h>
#endif
#endif /* HAVE_PCAP_PCAP_INTTYPES_H */
@@ -175,23 +173,17 @@
#ifdef _MSC_VER
/*
* Compiler is MSVC.
+ *
+ * We require VS 2015 or newer, so we have strtoll(). Use that for
+ * strtoint64_t().
*/
- #if _MSC_VER >= 1800
- /*
- * VS 2013 or newer; we have strtoll(). Use that for strtoint64_t().
- */
- #define strtoint64_t strtoll
- #else
- /*
- * Earlier VS; we don't have strtoll(), but we do have
- * _strtoi64(). Use that for strtoint64_t().
- */
- #define strtoint64_t _strtoi64
- #endif
+ #define strtoint64_t strtoll
/*
* Microsoft's documentation doesn't speak of LL as a valid
* suffix for 64-bit integers, so we'll just use i64.
+ *
+ * XXX - is that still the case as of VS 2015?
*/
#define INT64_T_CONSTANT(constant) (constant##i64)
#else