How to suppress -Wimplicit-function-declaration warning, if <stdlib.h> really does not have the declaration?

Jim DeLaHunt list+macports-dev at
Wed Jan 26 07:43:23 UTC 2022

Hello, MacPorts developers:

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:

#include <stdlib.h>
static void func(void)

main (void)
   return 0;

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:

% /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]
1 error generated.

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.

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().

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?

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?

I don't see other commits which mention this feature as part of implicit 
function declaration warnings[4].


[2] <>

[3] see links in 


[5] Verbose compilation output:

% /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/
  "/Applications/" -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/ -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:
  /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]
1 error generated.

Best regards,
     —Jim DeLaHunt, Vancouver, Canada

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the macports-dev mailing list