Re: How do I disable warnings across versions?

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

 



On 2012-05-15 15:05:02 +0200, Segher Boessenkool wrote:
> >>Note that you can test for the exact version of GCC with #ifdef
> >>GCC_MAJOR >= 4 && GCC_MINOR >= 7.
> >
> >They don't exist.
> 
> #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)

Hmm, yes, these macros are actually used by MPFR. Note that these
macros are also by Intel's compiler ICC, which tries to emulate
some GCC features, but doesn't behave exactly like GCC. :( This
is a problem for portable code.

For those interested, we currently have the following:

#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))

#if defined(_WIN32)
/* Under MS Windows (e.g. with VS2008 or VS2010), Intel's compiler doesn't
   support/enable extensions like the ones seen under GNU/Linux.
   https://sympa.inria.fr/sympa/arc/mpfr/2011-02/msg00032.html */
# define __MPFR_ICC(a,b,c) 0
#elif defined(__ICC)
# define __MPFR_ICC(a,b,c) (__ICC >= (a)*100+(b)*10+(c))
#elif defined(__INTEL_COMPILER)
# define __MPFR_ICC(a,b,c) (__INTEL_COMPILER >= (a)*100+(b)*10+(c))
#else
# define __MPFR_ICC(a,b,c) 0
#endif

#if defined(__GNUC__) && defined(__GNUC_MINOR__) && ! __MPFR_ICC(0,0,0)
# define __MPFR_GNUC(a,i) \
 (MPFR_VERSION_NUM(__GNUC__,__GNUC_MINOR__,0) >= MPFR_VERSION_NUM(a,i,0))
#else
# define __MPFR_GNUC(a,i) 0
#endif

> >GMP and MPFR have such macros. It would be a nice addition to GCC,
> >but with the __GCC prefix.
> 
> That's probably why it was added then, in prehistoric times already :-)

I wonder why GCC has two different prefixes: __GNUC for the versions
and __GCC for some other macros.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux