When building with a C++ compiler, remove the 'register' keyword to silent a warning
authorSylvestre Ledru <sylvestre@debian.org>
Sun, 5 Nov 2017 10:48:00 +0000 (11:48 +0100)
committerSylvestre Ledru <sylvestre@debian.org>
Sun, 5 Nov 2017 10:48:03 +0000 (11:48 +0100)
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

index 5efcbc0..71acfce 100644 (file)
--- a/lib/lz4.c
+++ b/lib/lz4.c
 #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) {