Future-proof the ./configure script - #28
Open
orlitzky wants to merge 5 commits into
Open
Conversation
One of the "does the compiler work?" test programs uses
int main(){ ... }
which disagrees with the usual definition of main(int, char**). To
ensure future compatibility with pedantic compilers, we correct the
test program.
Several of the ./configure test programs use
int main(){ ... }
which disagrees with the usual definition of main(int, char**). To
ensure future compatibility with pedantic compilers, we correct the
test programs.
Two ./configure test programs declare and define
int foo() { ... }
simultaneously. A strict reading of the C standard, however, requires
that we use
int foo(void) { ... }
so that the definition agrees with what its prototype would be. This
can be detected by the "strict-prototypes" warning in gcc or clang.
To test if connect() is available (and in what library, if any, it
lives), the ./configure script was compiling and linking
int main(int argc, char **argv) {
gethostbyname();
connect();
return 0;
}
This program, however, is invalid and fails to build with pedantic
compilers. The functions gethostbyname() and connect() are undefined;
and once we include the necessary headers to define them, they're
called incorrectly, with the wrong number/type of arguments.
The program is never actually *run*, so we fix this by including the
headers that define gethostbyname() and connect(), and then by
changing those two calls to pass correctly-typed junk arguments to the
functions.
This can be detected by the "implicit-function-declaration" warning in
gcc or clang.
Contributor
Author
|
It looks like GCC is in on the fun, too. Some other recent references: |
Contributor
Author
|
Ping? The future is fast approaching :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref: https://bugs.gentoo.org/870412
It's very likely that clang-16 will have
-Werror=implicit-function-declaration -Werror=implicit-int -Werror=strict-prototypesinCFLAGSby default. From what I understand, they tried to do it in a minor release of clang-15, but put it off until clang-16 because it breaks so many things.In any case, the
./configurescript for rbldnsd has some trouble with this. This series of commits fixes the issues on my Gentoo system and hopefully does not introduce new problems elsewhere.There is still one build failure remaining with
--enable-dso, but I don't think that feature was done cooking and I don't want to interrupt its slumber.