[Top][All Lists]

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

Re: [patch] Extend AC_PROG_CXX to check for standards conformance

From: Roger Leigh
Subject: Re: [patch] Extend AC_PROG_CXX to check for standards conformance
Date: Mon, 21 Jan 2013 13:46:13 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Jan 20, 2013 at 10:47:05PM -0800, Paul Eggert wrote:
> Thanks for doing that.
> I don't use C++, so I'm not the best person to review this patch.
> But from a quick look I can see one thing missing: the documentation
> needs updating.

Sure, I mentioned why it was missing in my mail.  I'll add it in
when I next post an updated patch.  If it's useful, I can also split
up the checks into individual feature tests for each
C++11/C++98TR1/C++98 language/library test, and have the general mode
tests aggregate these togther as they are now.

> One other thing:
> On 01/20/2013 01:27 PM, Roger Leigh wrote:
> > it's useful to restrict the compiler to a minimum standard
> > so that you can
> > - prevent the use of features you don't want to use
> > - ensure that the features you do want are present
> In practice, for C at least, almost nobody wants the
> former, and Autoconf already does the latter, so it's
> good enough.

For both C and C++, I think there are some considerations
here where it does make sense:

- If my project supports language standard n, enabling
  standard n+1 or n+2 enables language features which are
  actively harmful to use, since unintentional introduction
  of later language features will break building on systems
  which don't support it.

- If my project supports language standard n, and autoconf
  autodetects n-1, configure will succeed unless I do
  additional feature tests.  It will of course fail at
  compile time, but the fallbacks are essentially useless to

I'm using C++11 language features in my code.  These are unavailable
to me unless the compiler supports it natively, which may require
putting it into C++11 mode with -std=gnu++11 or equivalent.  With
this patch, AC_PROC_CXX will put the compiler into C++11 mode if
available, or it will fall back to C++98TR1 or C++98 (or earlier).
*None* of these fallbacks are helpful.  Using
AC_PROG_CXX_CXX11 clearly states that the system must have a C++11
compiler, or else bail out.  The same applies to C11/C99 etc.

Selecting the latest available standard is certainly useful as the
default, I don't disagree with that at all.  But if I need a
minimum compiler version, I don't want a fallback to an even earlier
version.  I need the minimum version or nothing.  This is completely
orthogonal to the feature tests I might perform with the compiler in a
particular standard mode; I need it to be in that mode to start with.

>From the other POV, if my code is written using ISO C89, having the
compiler in C99 or C11 modes is not /actively/ harmful.  But if I
really don't want those language features, AC_PROG_CC_C89 is the
minimum.  Now this might still leave the compiler in a higher mode;
we can't help that.  But, on compilers which do support -std=c89 or
equivalent, I've turned off the extra features which might get silently
introduced into my code, ultimately breaking stuff.  I'll catch them
as I'm developing, rather than after release.


  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux
 `. `'   schroot and sbuild
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800

reply via email to

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