Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails with clang version 16.0.4 and -pedantic-errors #212

Open
thass0 opened this issue Jun 19, 2023 · 0 comments
Open

Compilation fails with clang version 16.0.4 and -pedantic-errors #212

thass0 opened this issue Jun 19, 2023 · 0 comments

Comments

@thass0
Copy link

thass0 commented Jun 19, 2023

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?

@thass0 thass0 changed the title Compilation fails with clang and -pedantic-errors Compilation fails with clang version 16.0.4 and -pedantic-errors Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant