antirez / antirez/linenoise

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

Aperta
#212 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C
Stelle
4.4k
Fork
741
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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("");
^
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`?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.