autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AC_CHECK_DECLS vs. Clang


From: Noah Misch
Subject: AC_CHECK_DECLS vs. Clang
Date: Sun, 8 Mar 2015 00:13:44 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

The Clang compiler furnishes implicit declarations for built-in functions,
even when the identifier in question is not used as a function designator.
This thwarts AC_CHECK_DECLS:

configure:11565: checking whether strlcpy is declared
configure:11565: clang -c -Wall -Wmissing-prototypes -Wpointer-arith 
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute 
-Wformat-security -fno-strict-aliasing -fwrapv -g -O2  -D_GNU_SOURCE 
-I/usr/include/libxml2  conftest.c >&5
conftest.c:166:10: warning: implicitly declaring library function 'strlcpy' 
with type 'unsigned long (char *, const char *, unsigned long)'
  (void) strlcpy;
         ^
conftest.c:166:10: note: please include the header <string.h> or explicitly 
provide a declaration for 'strlcpy'
1 warning generated.
configure:11565: $? = 0
configure:11565: result: yes


Full config.log:
http://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=treepie&dt=2015-03-07%2006%3A22%3A38&stg=config

Clang has always behaved this way, but strlcpy() and strlcat() were unaffected
until Clang 3.0 added them as builtins.  To fix this, I plan to introduce
ac_c_decl_warn_flag by analogy to ac_c_preproc_warn_flag.  With no explicit
declarations, a typical compiler (ac_c_decl_warn_flag='') reports an error for
"(void) strchr;".  Clang (ac_c_decl_warn_flag=yes) reports a warning, but
adding a declaration silences the warning.  A compiler that emits some warning
with or without a declaration is unusable.  Is that a reasonable plan?

Thanks,
nm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]