libusb.h: Make C-preprocessor checks consistent and safe
Instead of mixing 'ifdef' with 'if defined(...)', use the latter
everywhere.
Check whether the __GNUC__ macro is defined before using it to avoid
compiler warnings.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
diff --git a/libusb/libusb.h b/libusb/libusb.h
index cba4409..2452d73 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -25,7 +25,7 @@
#ifndef LIBUSB_H
#define LIBUSB_H
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
/* on MS environments, the inline keyword is available in C++ only */
#if !defined(__cplusplus)
#define inline __inline
@@ -47,7 +47,7 @@
#define ZERO_SIZED_ARRAY /* [] - valid C99 code */
#else
#define ZERO_SIZED_ARRAY 0 /* [0] - non-standard, but usually working code */
-#endif
+#endif /* __STDC_VERSION__ */
/* 'interface' might be defined as a macro on Windows, so we need to
* undefine it so as not to break the current libusb API, because
@@ -62,13 +62,12 @@
#if !defined(__CYGWIN__)
#include <winsock.h>
#endif
-#endif
+#endif /* _WIN32 || __CYGWIN__ */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-#define LIBUSB_DEPRECATED_FOR(f) \
- __attribute__((deprecated("Use " #f " instead")))
-#elif __GNUC__ >= 3
-#define LIBUSB_DEPRECATED_FOR(f) __attribute__((deprecated))
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+#define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated ("Use " #f " instead")))
+#elif defined(__GNUC__) && (__GNUC__ >= 3)
+#define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated))
#else
#define LIBUSB_DEPRECATED_FOR(f)
#endif /* __GNUC__ */
@@ -109,7 +108,7 @@
#define LIBUSB_CALL WINAPI
#else
#define LIBUSB_CALL
-#endif
+#endif /* _WIN32 || __CYGWIN__ */
/** \def LIBUSB_API_VERSION
* \ingroup libusb_misc
@@ -136,7 +135,7 @@
/* The following is kept for compatibility, but will be deprecated in the future */
#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
-#ifdef __cplusplus
+#if defined(__cplusplus)
extern "C" {
#endif
@@ -2070,7 +2069,7 @@
int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
-#ifdef __cplusplus
+#if defined(__cplusplus)
}
#endif
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 09911df..ac0929f 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11494
+#define LIBUSB_NANO 11495