summaryrefslogtreecommitdiff
path: root/pcap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-08-09 14:49:08 -0700
committerGuy Harris <guy@alum.mit.edu>2019-08-09 14:49:08 -0700
commit28e59ef688d13addc6fb5df8362ad61ac6ce826d (patch)
treebd4a5f3b4d97b78aaddf749e2c7e7123b54f74cc /pcap
parentf773b1c56122feaff9e9ecabbde3326b7c081233 (diff)
downloadlibpcap-28e59ef688d13addc6fb5df8362ad61ac6ce826d.tar.gz
Remove some workarounds for old compilers.
Require Visual Studio 2015 or later; fail if we don't have it, and remove checks for older versions. That means we have C99-compliant snprintf() and vsnprintf(); require them when configuring for UN*X, and then use them directly, rather than having wrappers for systems lacking them. If we're using MSVC, skip the tests for options to request C99 compatibility - either we have VS 2015, which is sufficient, or we don't, in which case we fail.
Diffstat (limited to 'pcap')
-rw-r--r--pcap/funcattrs.h12
-rw-r--r--pcap/pcap-inttypes.h54
2 files changed, 25 insertions, 41 deletions
diff --git a/pcap/funcattrs.h b/pcap/funcattrs.h
index e64da93a..687cbbd4 100644
--- a/pcap/funcattrs.h
+++ b/pcap/funcattrs.h
@@ -233,10 +233,10 @@
* __attribute__((deprecated(msg))).
*/
#define PCAP_DEPRECATED(func, msg) __attribute__((deprecated))
-#elif (defined(_MSC_VER) && (_MSC_VER >= 1500)) && !defined(BUILDING_PCAP)
+#elif (defined(_MSC_VER) && !defined(BUILDING_PCAP)
/*
- * MSVC from Visual Studio 2008 or later, and we're not building
- * libpcap itself.
+ * MSVC, and we're not building libpcap itself; it's VS 2015
+ * or later, so we have the deprecated pragma.
*
* If we *are* building libpcap, we don't want this, as it'll warn
* us even if we *define* the function.
@@ -251,11 +251,7 @@
*/
#ifdef _MSC_VER
#include <sal.h>
- #if _MSC_VER > 1400
- #define PCAP_FORMAT_STRING(p) _Printf_format_string_ p
- #else
- #define PCAP_FORMAT_STRING(p) __format_string p
- #endif
+ #define PCAP_FORMAT_STRING(p) _Printf_format_string_ p
#else
#define PCAP_FORMAT_STRING(p) p
#endif
diff --git a/pcap/pcap-inttypes.h b/pcap/pcap-inttypes.h
index af2c23c8..afd520b7 100644
--- a/pcap/pcap-inttypes.h
+++ b/pcap/pcap-inttypes.h
@@ -33,47 +33,41 @@
/*
* Get the integer types and PRi[doux]64 values from C99 <inttypes.h>
- * defined, by hook or by crook.
+ * 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.
*/
#if defined(_MSC_VER)
/*
- * Compiler is MSVC.
+ * Compiler is MSVC. Make sure we have 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.
- */
- 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
+ #if _MSC_VER < 1900
+ #error "Building libpcap requires VS 2015 or later"
#endif
/*
* These may be defined by <inttypes.h>.
*
+ * 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,
* then they should probably use the _MSC_EXTENSIONS even if the
* compiler doesn't define _MSC_EXTENSIONS.
- *
- * XXX - we currently aren't using any of these, but this allows
- * their use in the future.
*/
#ifndef PRId64
#ifdef _MSC_EXTENSIONS
@@ -106,12 +100,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 /* pcap/pcap-inttypes.h */