coreutils
[Top][All Lists]
Advanced

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

ifdef HAVE_DECL_


From: Karel Zak
Subject: ifdef HAVE_DECL_
Date: Wed, 13 Jun 2012 11:32:33 +0200
User-agent: Mutt/1.5.21 (2011-07-01)

 Hi,

 autoconf docs about AC_CHECK_DECLS:

   Unlike the other ‘AC_CHECK_*S’ macros, when a symbol is not
   declared, HAVE_DECL_symbol is defined to ‘0’ instead of leaving
   HAVE_DECL_symbol undeclared. When you are sure that the check was
   performed, use HAVE_DECL_symbol in #if:

        #if !HAVE_DECL_SYMBOL
           extern char *symbol;
        #endif

 This is also valid for AC_CHECK_DECLS_ONCE.

 It means that use #ifdef or #ifndef for HAVE_DECL_* is very probably bug.

 Let's quickly check our code for #ifdef:

 $ grep -r  '[[:blank:]]*#[[:blank:]]*ifdef[[:blank:]]*HAVE_DECL_' *
 gnulib/lib/argp-parse.c:#ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
 gnulib/lib/argp-parse.c:#ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME


 More complex (and I hope without false positives) solution:

 for decl in $(awk '/define HAVE_DECL_.*ac_have_decl/ { print $2 }' configure); 
do 
    grep -rnE '[[:blank:]]*#[[:blank:]]*if(ndef|def)[[:blank:]]*'$decl *; done 
| sort -u

 configure:45306:#ifndef HAVE_DECL_STRNDUP
 gnulib/lib/argp-parse.c:882:#ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
 gnulib/lib/argp-parse.c:886:#ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
 gnulib/lib/error.c:103:#  ifndef HAVE_DECL_STRERROR_R
 gnulib/lib/fpending.h:24:#ifndef HAVE_DECL___FPENDING
 gnulib/lib/strtoimax.c:31:# ifndef HAVE_DECL_STRTOULL
 gnulib/lib/strtoimax.c:40:# ifndef HAVE_DECL_STRTOLL
 gnulib/m4/strndup.m4:27:#ifndef HAVE_DECL_STRNDUP
 lib/error.c:103:#  ifndef HAVE_DECL_STRERROR_R
 lib/fpending.h:24:#ifndef HAVE_DECL___FPENDING
 lib/strtoimax.c:31:# ifndef HAVE_DECL_STRTOULL
 lib/strtoimax.c:40:# ifndef HAVE_DECL_STRTOLL
 m4/strndup.m4:27:#ifndef HAVE_DECL_STRNDUP


 Bugs?

    Karel

-- 
 Karel Zak  <address@hidden>
 http://karelzak.blogspot.com



reply via email to

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