summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-04-16 14:26:42 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2020-04-16 14:26:42 -0700
commite990e48fa85e73cd16f2f0b4b02037d8c287d22f (patch)
treeaf1c042a8443e8313b2aa407b12d1f2f85c7775d
parentb832e9f03ac32cfe23b6962007f53d781d8231b9 (diff)
downloadlibusb-e990e48fa85e73cd16f2f0b4b02037d8c287d22f.tar.gz
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>
-rw-r--r--libusb/libusb.h21
-rw-r--r--libusb/version_nano.h2
2 files changed, 11 insertions, 12 deletions
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 @@ 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
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