<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello, MacPorts developers:</p>
<p>I am attempting to resolve a -Wimplicit-function-declaration
generated by the ./configure code[1] of a port. The relevant code
appears to be checking if the C11 feature std::at_quick_exit()[2]
is defined. The configure code expands to:</p>
<pre>#include <stdlib.h>
static void func(void)
{}
int
main (void)
{
at_quick_exit(func);
;
return 0;
}</pre>
<p>When I attempt to compile it with clang as provided by XCode
11.2.1 (11B5000) on macOS 10.14.6 Mojave, I get the
-Wimplicit-function-declaration warning:</p>
<pre>% /usr/bin/clang -o conftest -std=c11 -I/opt/local/include -Werror -Wall -Wpointer-arith -Wcast-align -Wno-tautological-compare -L/opt/local/libexec/qt5/lib -L/opt/local/lib conftest.c -liconv
conftest.c:99:2: error: implicit declaration of function 'at_quick_exit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
at_quick_exit(func);
^
1 error generated.
%
</pre>
<p>Most of the instructions about resolving
-Wimplicit-function-declaration warning[3] assume code which does
not include the appropriate system header, and suggest adding the
system header. <br>
</p>
<p>But this code does have the right system header:
<stdlib.h>. It looks like that header does not include a
declaration of at_quick_exit(). Thus the call to at_quick_exit()
in the main function is in fact an implicit function declaration,
and the warning is appropriate. Let's assume that is correct; that
this compiler and its includes and libraries really do not have
at_quick_exit(). Maybe some other compilers or versions do have
it. And let's assume that this configure code fails correctly, and
thus configures correctly in the absence of at_quick_exit().</p>
<p>Is it significant that the error message mentions "C99", when I
am passing the compiler the option "-std=c11"? Have I failed to
get the compiler into C11 support mode?<br>
</p>
<p>How can I patch this code so that it passes where the feature is
defined, and fails where the feature is not, and does not result
in MacPorts displaying a warning in the main.log file when
building the port?<br>
</p>
<p>I don't see other commits which mention this feature as part of
implicit function declaration warnings[4].<br>
</p>
[1]
<a class="moz-txt-link-rfc2396E" href="https://github.com/freeciv/freeciv/blob/15de591c1ce0e8b7abd717d034cdf4cd6326ddfa/m4/c11.m4#L32-L51"><https://github.com/freeciv/freeciv/blob/15de591c1ce0e8b7abd717d034cdf4cd6326ddfa/m4/c11.m4#L32-L51></a><br>
<p>[2]
<a class="moz-txt-link-rfc2396E" href="https://en.cppreference.com/w/cpp/utility/program/at_quick_exit"><https://en.cppreference.com/w/cpp/utility/program/at_quick_exit></a></p>
<p>[3] see links in
<a class="moz-txt-link-rfc2396E" href="https://trac.macports.org/wiki/WimplicitFunctionDeclaration"><https://trac.macports.org/wiki/WimplicitFunctionDeclaration></a></p>
<p>[4]
<a class="moz-txt-link-rfc2396E" href="https://github.com/macports/macports-ports/search?q=at_quick_exit&type=commits"><https://github.com/macports/macports-ports/search?q=at_quick_exit&type=commits></a></p>
<p>[5] Verbose compilation output:</p>
<pre>% /usr/bin/clang -v -o conftest -std=c11 -I/opt/local/include -Werror -Wall -Wpointer-arith -Wcast-align -Wno-tautological-compare -L/opt/local/libexec/qt5/lib -L/opt/local/lib conftest.c -liconv
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name conftest.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version 520 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I /opt/local/include -I/usr/local/include -Werror -Wall -Wpointer-arith -Wcast-align -Wno-tautological-compare -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-extra-semi-stmt -Wno-quoted-include-in-framework-header -std=c11 -fdebug-compilation-dir /Users/jdlh/workspace/freeciv_overall/freeciv_S2_6 -ferror-limit 19 -fmessage-length 132 -stack-protector 1 -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/5p/zmlrjq6c8xj84s0059bnypz80000gp/T/conftest-c6e47f.o -x c conftest.c
clang -cc1 version 11.0.0 (clang-1100.0.33.12) default target x86_64-apple-darwin18.7.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/opt/local/include
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
conftest.c:99:2: error: implicit declaration of function 'at_quick_exit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
at_quick_exit(func);
^
1 error generated.
</pre>
<p>Best regards,
<br>
—Jim DeLaHunt, Vancouver, Canada
</p>
<p><br>
</p>
<p><br>
</p>
</body>
</html>