Re: C++ pre-processor flags not updated by ax_cxx_compile_stdcxx.m4
Moritz Klammler <[email protected]> Mon, 21 Mar 2016 22:30:59 +0100
| Newsgroups | gmane.comp.sysutils.autoconf.archive-maintainers |
|---|---|
| Message-ID | <[email protected]> |
Thanks, I can confirm this. It seems that this is documented (if maybe
not desired) behavior. The documentation [1] of the `AC_PROG_CXXCPP`
macro says:
> Set output variable `CXXCPP` to a command that runs the C++
> preprocessor. If `$CXX -E` doesn't work, `/lib/cpp` is used. It is
> only portable to run `CXXCPP` on files with a `.c`, `.C`, or `.cc`
> extension.
Therefore, if you invoke `AC_PROG_CXXCPP` *before*
`AX_CXX_COMPILE_STDCXX`, the standard selection switch does not affect
the pre-processor. The solution is to call the macros in this order:
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_14
AC_PROG_CXXCPP
# Check for headers ...
This ordering dependency might not be pretty, but I don't see anything
we could do about it at this point.
Alternatively, if you don't actually need it, you could consider leaving
out the call to `AC_PROG_CXXCPP` completely.
[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.61/html_node/C_002b_002b-Compiler.html
Kip Warner <[email protected]> writes:
> [[PGP Signed Part:No public key for 2D79DF2BB6E28B6D created at 2016-03-21T00:34:15+0100 using DSA]]
> On Sat, 2016-03-19 at 04:53 +0100, Moritz Klammler wrote:
>> Are you using the latest version of `AX_CXX_COMPILE_STDCXX` [1]? I
>> think this should have been fixed by Joshua's latest patch [2] which
>> changed the macro to append the `-std=c++14` flag to the `CXX` rather
>> than to the `CXXFLAGS` variable so the pre-processor should now pick
>> it up as well.
>
> Hey Moritz. Yes, I am using the latest release from [1].
>
>> I've tested with the following setup and it seems to work properly
>> with the latest version.
>>
>> $ ls
>> configure.ac m4/
>>
>> $ cat configure.ac
>> AC_PREREQ([2.69])
>> AC_INIT([example], [1.0], [[email protected]])
>> AC_CONFIG_MACRO_DIR([m4])
>> AC_PROG_CXX
>> AX_CXX_COMPILE_STDCXX_14
>> AC_LANG_PUSH([C++])
>> AC_CHECK_HEADERS([initializer_list])
>> AC_LANG_POP([C++])
>> AC_OUTPUT
>>
>> $ ls m4/
>> ax_cxx_compile_stdcxx.m4 ax_cxx_compile_stdcxx_14.m4
>>
>> $ autoreconf && ./configure
>> # ...
>
> I confirm the same results. However, if you add AC_PROG_CXXCPP just
> before the AX_CXX_COMPILE_STDCXX_14 expansion, I see the following:
>
> $ ./configure
> checking for g++... g++
> checking whether the C++ compiler works... yes
> checking for C++ compiler default output file name... a.out
> checking for suffix of executables...
> checking whether we are cross compiling... no
> checking for suffix of object files... o
> checking whether we are using the GNU C++ compiler... yes
> checking whether g++ accepts -g... yes
> checking how to run the C++ preprocessor... g++ -E
> checking whether we are using the GNU C++ compiler... (cached) yes
> checking whether g++ accepts -g... (cached) yes
> checking whether g++ supports C++14 features by default... no
> checking whether g++ supports C++14 features with -std=gnu++14... yes
> checking for grep that handles long lines and -e... /bin/grep
> checking for egrep... /bin/grep -E
> checking for ANSI C header files... yes
> checking for sys/types.h... yes
> checking for sys/stat.h... yes
> checking for stdlib.h... yes
> checking for string.h... yes
> checking for memory.h... yes
> checking for strings.h... yes
> checking for inttypes.h... yes
> checking for stdint.h... yes
> checking for unistd.h... yes
> checking initializer_list usability... yes
> checking initializer_list presence... no
> configure: WARNING: initializer_list: accepted by the compiler, rejected by the preprocessor!
> configure: WARNING: initializer_list: proceeding with the compiler's result
> checking for initializer_list... yes
> configure: creating ./config.status
>
> I hope that helps.
--
OpenPGP:
Public Key: http://openpgp.klammler.eu
Fingerprint: 2732 DA32 C8D0 EEEC A081 BE9D CF6C 5166 F393 A9C0
signature.asc
(application/pgp-signature, 472 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJW8GgTAAoJEM9sUWbzk6nAT7MIANSbMqqYyqgMmS5ejrEO8tt8 KVcNDNc8nvQYxogr3s7OYnEB5mhRoBnoTo8WbVmuN1oM5ZcOu6qLX97QbyhjHtOp tKFH6te0V6iPvnKfLtLNvMiT0h3X3iSUAnxk35PMPL0rKGb0xOPv+BH/O9+KMXNa h95JBpI2aua2XtjXXmLnLGUAshB7PtpXHRZkGlxoRRfNXABKIiFRl6znhjOLMuls A4U7ge8zOVzyPZNALzH7ngPU/OHXapTZRPU9mx3M/xQa5xMkMcX9vbxv2KET9Yf6 fN1SC8imUQnmRRdq0QcOkqmSlUChuJU8gSWJEAaztr4bG1EkfVM1WAjMvpVPbqs= =bUhb -----END PGP SIGNATURE-----