[Top][All Lists]

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

Re: [PATCH 2/5] stat-time: use extern-inline

From: Eric Blake
Subject: Re: [PATCH 2/5] stat-time: use extern-inline
Date: Wed, 15 Aug 2012 06:49:29 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0

On 08/14/2012 08:01 PM, Paul Eggert wrote:
> On 08/14/2012 02:14 PM, Eric Blake wrote:
>> It would mean
>> every client of our static inline macros would have to declare
>> independently from the implementation, if they are worried about
>> warning-free compilation on older gcc versions.
> It'd be a real hassle to declare every inline function twice,
> just to pacify older GCCs.  (When this issue comes up with Emacs,
> the usual advice is "don't use --enable-gcc-warnings if your
> GCC is older than the latest version".)
>> I'm having a tough time
>> figuring out how to conditionally disable a particular warning (I want
>> the -Wmissing-prototypes warning with newer gcc, just not when
>> targetting an older gcc that can't push and pop warning levels).
> Since it's just GCC, can you use "gcc --version" to decide whether
> to use -Wmissing-prototypes?

This is what I came up with for libvirt, so no need to patch gnulib
after all:

+++ b/m4/virt-compile-warnings.m4
     # Gnulib's stat-time.h violates this
     dontwarn="$dontwarn -Waggregate-return"

+    # Gnulib uses '#pragma GCC diagnostic push' to silence some
+    # warnings, but older gcc doesn't support this.
+    AC_CACHE_VAL([lv_cv_gcc_pragma_push_works], [
+      save_CFLAGS=$CFLAGS
+      CFLAGS=-Wunknown-pragmas
+        #pragma GCC diagnostic push
+        #pragma GCC diagnostic pop
+      ]])],
+      [lv_cv_gcc_pragma_push_works=yes],
+      [lv_cv_gcc_pragma_push_works=no])
+      CFLAGS=$save_CFLAGS])
+    if test $lv_cv_gcc_pragma_push_works = no; then
+      dontwarn="$dontwarn -Wmissing-prototypes"
+      dontwarn="$dontwarn -Wmissing-declarations"
+    fi

The list is extensible if any other new warnings crop up with older gcc,
without tying things to explicit compiler versions (you never know - the
RHEL gcc might decide to backport some warning option patches without
bumping the 'gcc --version' output, and we do preach that feature tests
are always better than version tests).

Hmm, and just re-reading that now, I realized I could use an
AC_CACHE_CHECK instead of AC_CACHE_VAL for nicer configure output.

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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