antirez/linenoise

Compilation fails with clang version 16.0.4 and `-pedantic-errors`

thass0 opened this issue · 0 comments

thass0 commented

When I run clang linenoise.c -c -pedantic-errors I get the following error messages:

linenoise.c:622:31: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
            lndebug("clear+up");
                              ^
linenoise.c:184:9: note: macro 'lndebug' defined here
#define lndebug(fmt, ...)
        ^
linenoise.c:630:24: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
        lndebug("clear");
                       ^
linenoise.c:184:9: note: macro 'lndebug' defined here
#define lndebug(fmt, ...)
        ^
linenoise.c:654:32: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
            lndebug("<newline>");
                               ^
linenoise.c:184:9: note: macro 'lndebug' defined here
#define lndebug(fmt, ...)
        ^
linenoise.c:683:17: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
    lndebug("\n");
                ^
linenoise.c:184:9: note: macro 'lndebug' defined here
#define lndebug(fmt, ...)
        ^
4 errors generated.

I was able to fix this by changing the default signature of the lndebug macro macro:

@@ -181,7 +181,7 @@ FILE *lndebug_fp = NULL;
         fflush(lndebug_fp); \
     } while (0)
 #else
-#define lndebug(fmt, ...)
+#define lndebug(...)
 #endif

This way it has the same signature as the implementation used when debugging is enabled. Because of this I figured it should behave the same way it did previously. The downside of this change is that now if one doesn't compile with both clang and -pedantic-errors, lndebug could be called without any arguments at all. Since this is already the case with the actual implementation though it seems to me like this doesn't really matter.

Is there any reason why lndebug requires the fmt parameter and could this potentially be changed to allow clang -pedantic-errors?