autoconf
[Top][All Lists]
Advanced

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

Re: conditionally compiling C++ code [#7938]


From: Tim Van Holder
Subject: Re: conditionally compiling C++ code [#7938]
Date: Thu, 24 Apr 2003 08:29:41 +0200

> > AC_PROG_CXX checks whether it can find a working C++ 
> compiler. Is it a 
> > problem to *know* this if you're not going to use it?
> 
> Yes, it's a problem.
> 
> As far as I can tell, including AC_PROG_CXX in configure.ac
> results in configure testing for a working C++ pre-processor,
> and when one isn't found, configure fails.

I thought AC_PROG_CXX did not do any checks if CXX is set - so
you could just set CXX to 'no'.
But I find that's not the case, so that doesn't help much.

I also noticed that autoconf's check for the default output is
broken.  ac_file is used to iterate over all known outputs,
but it is also used as result field.  This means that if none
of the possible outputs are found (as was the case after setting
CXX to 'true' to see if that helped), it reports finding the
last one in the list (b.out).

> For example, it might make sense to have AC_PROG_CXX have a
> no-such-compiler value for CXX, which would then be tested
> before dependent tests, like for a C++ preprocessor, are done.
> (That was the first workaround we tried -- see if AC_PROG_CXX
> has failed, and wrap the tests that fail in if/else of CXX's
> "failed" value.
> 
> That doesn't work because there is no CXX failure value.  If
> AC_PROG_CXX can't find a compiler, it sets CXX to "g++" (that
> makes no sense to me, but I don't know enough about autoconf
> to have the right to an opinion.)

I _think_ this was for backwards compatibility - but given that
this automatically means that the rest of the checks fail and
abort the configure (except perhaps when cross-compiling), I'd
agree setting it to 'no' (like most other similar tests do IIRC)
is a lot better (provided the rest of the tests are then suitably
skipped, of course).
This does mean a change in semantics for the macro tho, so maybe
it should be a separate macro (AC_PROG_CXX_OPTIONAL?).  This could
do the check for the compiler, with 'no' as the default, and then
run AC_PROG_CXX (which would have subtests that respect the 'no'
value).  Since CXX will be set, it will not check again, and if
AC_PROG_CXX is run, it will do the normal check + g++ default.

(I'm sure Akim will now say - "OK Tim, thanks for volunteering
to make a patch" :-) )





reply via email to

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