-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Compile Under -pedantic -Werror
and -std=c90
#2099
Conversation
-pedantic -Werror
-pedantic -Werror
and -std=c90
Looks like the failing test is just noise, but this looks good to me once all the CI is passing! |
We will need to compile with |
The proposed solution looks good to me. |
Even without `-pedantic`, these macros will now fail to compile unless you provide an info string argument. This will prevent us from regressing.
`-Wall` implies `-Wformat-zero-length`, which will cause compilation to fail under `-Werror` when an empty string is passed as the format string to a `printf`-family function. This commit moves us back to prefixing the provided format string, which successfully avoids that warning. However, this removes the failure mode where that `RAWLOG` invocation would fail to compile when no format string was provided at all (which was desirable to avoid having code that would successfully compile normally but fail under `-pedantic`, which *does* require that a non-zero number of args are provided). So this commit also introduces a function which does nothing at all, but will fail to compile if not provided with at least one argument, which is a string. This successfully links the compilability of pedantic and non-pedantic builds.
Previously we would use it for all gcc-like compilations, even when a restrictive mode that disallowed it had been selected.
It was causing build issues in ANSI mode.
It's complaining about the `memcpy`s, saying: "warning C4090: 'function': different 'const' qualifiers" Let's try explicitly casting to the argument types...
56bcf6e
to
2cf72d5
Compare
This changeset allows Zstd to be built without warnings under
-pedantic
. Specifically, this was tested with:This addresses #2035. See also previous threads on this topic: #1989, #1540, and #1538.
It also lets Zstd build successfully (though not without warnings) under C90/C89/ANSI mode.
This PR accomplishes this in a different way than previous solutions. Rather than diverge into two kinds of macros with and without additional arguments, it simply complies with C99 by making sure every invocation of these macros does have at least one argument.
Known deficiencies:
RETURN_ERROR_IF
,RETURN_ERROR
, andFORWARD_IF_ERROR
must have an info string.Why I selected this approach: adding
, ""
to the args is no more characters than adding_MSG
to the name of the macro, and I'd rather bias contributors towards including explanatory text than away.That being said, we could also introduce versions of these macros that don't take additional arguments. I'm open to suggestions.