X-Git-Url: http://git.linex4red.de/pub/lufa.git/blobdiff_plain/995195a2b06142fb0882cf116a12bdab8e19603f..3309c00a99cca6d4a903aed9ecd092346b767ea0:/LUFA/Common/Endianness.h diff --git a/LUFA/Common/Endianness.h b/LUFA/Common/Endianness.h index ef8c1a788..58f8012c1 100644 --- a/LUFA/Common/Endianness.h +++ b/LUFA/Common/Endianness.h @@ -56,6 +56,11 @@ #ifndef __LUFA_ENDIANNESS_H__ #define __LUFA_ENDIANNESS_H__ + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_COMMON_H) #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. @@ -78,7 +83,7 @@ * * \return Input value with the byte ordering reversed. */ - #define SWAPENDIAN_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) + #define SWAPENDIAN_16(x) (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) /** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings * of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used @@ -91,8 +96,8 @@ * * \return Input value with the byte ordering reversed. */ - #define SWAPENDIAN_32(x) ((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \ - (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL)) + #define SWAPENDIAN_32(x) (uint32_t)((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \ + (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL)) #if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu) #define le16_to_cpu(x) SwapEndian_16(x) @@ -461,6 +466,11 @@ } } + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */