From: Hans U. N. <hu...@n-...> - 2010-01-29 11:09:06
|
The libusb_cpu_to_le16 macro was a ({ ... }) expression, which generates the following compiler warning every time it is used, (and that is several times for every #include <libusb.h>): libusb.h:880: warning: ISO C forbids braced-groups within expressions With this patch, #include <libusb.h> stops generating compiler warnings on gcc 4.4. As libusb.h heavily relies on the use of static inline functions those can be relied on to work properly, and there should not be any significant difference in the code the compiler generates. --- libusb/libusb.h | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libusb/libusb.h b/libusb/libusb.h index 2dbb9a5..29a7d20 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -39,16 +39,16 @@ extern "C" { * \param x the host-endian value to convert * \returns the value in little-endian byte order */ -#define libusb_cpu_to_le16(x) ({ \ - union { \ - uint8_t b8[2]; \ - uint16_t b16; \ - } _tmp; \ - uint16_t _tmp2 = (uint16_t)(x); \ - _tmp.b8[1] = _tmp2 >> 8; \ - _tmp.b8[0] = _tmp2 & 0xff; \ - _tmp.b16; \ -}) +static inline uint16_t libusb_cpu_to_le16(const uint16_t x) +{ + union { + uint8_t b8[2]; + uint16_t b16; + } _tmp; + _tmp.b8[1] = x >> 8; + _tmp.b8[0] = x & 0xff; + return _tmp.b16; +} /** \def libusb_le16_to_cpu * \ingroup misc -- 1.6.2.5 |