libusb.h: Make C-preprocessor checks consistent and safe
authorChris Dickens <christopher.a.dickens@gmail.com>
Thu, 16 Apr 2020 21:26:42 +0000 (14:26 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 16 Apr 2020 21:26:42 +0000 (14:26 -0700)
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>
libusb/libusb.h
libusb/version_nano.h

index cba4409..2452d73 100644 (file)
@@ -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 @@ typedef SSIZE_T ssize_t;
 #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 @@ typedef SSIZE_T ssize_t;
 #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 @@ typedef SSIZE_T ssize_t;
 #define LIBUSB_CALL WINAPI
 #else
 #define LIBUSB_CALL
-#endif
+#endif /* _WIN32 || __CYGWIN__ */
 
 /** \def LIBUSB_API_VERSION
  * \ingroup libusb_misc
@@ -136,7 +135,7 @@ typedef SSIZE_T ssize_t;
 /* 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 @@ enum libusb_option {
 
 int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
 
-#ifdef __cplusplus
+#if defined(__cplusplus)
 }
 #endif
 
index 09911df..ac0929f 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11494
+#define LIBUSB_NANO 11495