From cca7618f09b0a98b05a27597f25fcdc68ab908ed Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 5 Nov 2017 11:48:00 +0100 Subject: [PATCH] When building with a C++ compiler, remove the 'register' keyword to silent a warning For example, with clang: lz4.c:XXX:36: error: 'register' storage class specifier is deprecated and incompatible with C++17 [-Werror,-Wdeprecated-register] static unsigned LZ4_NbCommonBytes (register reg_t val) ^~~~~~~~~ --- lib/lz4.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/lz4.c b/lib/lz4.c index 5efcbc0..71acfce 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -85,6 +85,17 @@ #endif +/* + * register is ignored when the code built with a C++ compiler + * Remove the keyword when built with C++ to silent the warning + */ +#ifdef __cplusplus +# define REGISTER +#else +# define REGISTER register +#endif + + /*-************************************ * Dependency **************************************/ @@ -330,7 +341,7 @@ static const int LZ4_minLength = (MFLIMIT+1); /*-************************************ * Common functions **************************************/ -static unsigned LZ4_NbCommonBytes (register reg_t val) +static unsigned LZ4_NbCommonBytes (REGISTER reg_t val) { if (LZ4_isLittleEndian()) { if (sizeof(val)==8) { -- 2.7.4