aboutsummaryrefslogtreecommitdiff
path: root/portability.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-08-02 16:12:21 -0700
committerGuy Harris <guy@alum.mit.edu>2016-08-02 16:12:21 -0700
commit77b2dcd1ee94b0a24446a0d9ab1740c58b4a93e6 (patch)
tree98765f0ac0b381e47f3f298aac0f5394ab5c54af /portability.h
parente4178a5524b25b7d9f4b4323aa97cb3ed2647df6 (diff)
Move definition of HAVE_SNPRINTF to portability.h.
It's not needed by pcap.h, so don't pollute the namespace with it. Declare pcap_snprintf() as being printf-like for the benefit of GCC and compatible compilers while we're at it.
Diffstat (limited to 'portability.h')
-rw-r--r--portability.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/portability.h b/portability.h
index ec1fd113..aa24c689 100644
--- a/portability.h
+++ b/portability.h
@@ -94,6 +94,18 @@ char *tokbuf;
#define strltok strtok
#endif
+#ifdef _MSC_VER
+ /*
+ * MSVC.
+ */
+ #if _MSC_VER >= 1900
+ /*
+ * VS 2015 or newer; we have snprintf() function.
+ */
+ #define HAVE_SNPRINTF
+ #endif
+#endif
+
/*
* On Windows, snprintf(), with that name and with C99 behavior - i.e.,
* guaranteeing that the formatted string is null-terminated - didn't
@@ -119,7 +131,11 @@ char *tokbuf;
#ifdef HAVE_SNPRINTF
#define pcap_snprintf snprintf
#else
-extern int pcap_snprintf(char *, size_t, FORMAT_STRING(const char *), ...);
+extern int pcap_snprintf(char *, size_t, FORMAT_STRING(const char *), ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
#endif
#ifdef HAVE_VSNPRINTF