autoconf
[Top][All Lists]
Advanced

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

Re: Selecting a C++ standard


From: Adrian Bunk
Subject: Re: Selecting a C++ standard
Date: Sun, 28 Oct 2012 23:45:35 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Oct 28, 2012 at 11:07:23AM +0000, Roger Leigh wrote:
> On Sun, Oct 28, 2012 at 03:00:01AM +0300, Adrian Bunk wrote:
> > On Sat, Oct 27, 2012 at 10:47:50PM +0100, Roger Leigh wrote:
>...
> > > Maybe have an optional argument to AC_PROG_CC_STDC to select
> > > the standard e.g.
> > >   AC_PROG_CC_STDC([C99])
> > > ?
> > 
> > Latest discussion result was that there is no downside of setting the 
> > compiler to the highest mode possible.
> 
> There isn't any downside I'm aware of.  But that's somewhat
> different than saying, "I need at least this version of the
> standard".  If I say I want C99, then C11 or C99 are both
> acceptable results.  But C89 is totally useless.
> 
> As described in this thread, the AC_PROG_CC fallbacks are
> useless (for me).  If I want C11, it can't guarantee it.  If I
> want C99, it can't guarantee it.  I need to be able to specify
> the minimum standard conformance required, and have autoconf
> try to satisfy that.  If it can't do that, then what exactly
> is the point of it?

The general problem is that your "If I want C99" only makes sense in
a theoretical world where all compilers implement exactly the complete 
standard, not any subset or superset.

In the real world, what a compiler supports in C99 mode can be a subset 
of C99 plus several C11 features (plus compiler specific features).
gcc 4.7 in it's gnu99 mode is an example for that. 

And that might or might not cover all features your code uses.

Let's make an example.

Facts:
- "long long" is not in C89, but is in C99
- gcc in it's default C89 mode supports "long long"
- gcc in it's strictest C89 setting gives a compile error on "long long"
- gcc does not fully support C99

When the only non-C89 feature you use in your code is "long long", 
then you are not interested in
- whether the compiler is in C89 or in C99 mode, or
- whether the compiler supports all other parts of the C99 standard

What you want is that:
1. if the compiler supports "long long" in some mode, it should be set
   into a mode where it supports that and
2. test whether the compiler supports "long long"

As of autoconf master, AC_PROG_CC does 1. automatically for you.

>...
> Regards,
> Roger

cu
Adrian

BTW: Please Cc me on replies.

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed




reply via email to

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