[Top][All Lists]

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

Re: manywarnings for C++

From: Reuben Thomas
Subject: Re: manywarnings for C++
Date: Wed, 22 Feb 2017 13:55:08 +0000

On 21 February 2017 at 14:58, Bruno Haible <address@hidden> wrote:
Hi Reuben,

This looks reasonable: Since a project can use both gcc and g++ and since the
desired warning options for gcc and g++ are likely different, it's good to
have different macros, that set different variables (WARN_CFLAGS vs.

​Thanks very much for the detailed guidance.​

Going further, there is no real benefit of having manywarnings-cxx a different
module. Since an m4 macro that is not invoked does not contribute to the size
nor the execution time of the 'configure' script, I would just add the two
new macros gl_MANYWARN_ALL_GXX and gl_CXX_WARN_ADD - in manywarnings.m4
and warnings.m4, respectively.

However, two things are important:
  - That the name of the *_cv_* variables are different in the C++ macro
    than in the C macro.

  - That you invoke AC_LANG_PUSH([C++]) at the beginning and AC_LANG_POP([C++])
    at the end of the macro, so that AC_LANG_SOURCE invocations do the right

​Done, but do I also need to add an AC_LANG_PUSH/POP([C]) at the beginning and end of gl_MANYWARN_ALL_GCC?​ If not, why not? (Is C assumed as the default?)

Please also fix the AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) invocation
in gl_WARN_ADD and gl_CXX_WARN_ADD. Since this macro expands to different
code after AC_LANG_PUSH([C++]) than after AC_LANG_PUSH([C]), it is wrong
to just AC_REQUIRE it. Needs to be a bit more intelligent.

Look at how _AC_LANG_ABBREV and _AC_LANG_PREFIX can be used. Maybe libtool.m4,
which also plays around with AC_LANG, gives you some hint about this.

I didn't fully understand this bit. I see that _AC_LANG_ABBREV/_AC_LANG_PREFIX are used to inject the name of the language into the names of variables. I see that gl_UNKNOWN_WARNINGS_ARE_ERRORS changes depending on the language because gl_COMPILER_OPTION_IF changes. (By the way, can we now assume autoconf 2.64 (of July 2009) or newer and hence quote gl_Warn, as per the comment, there?)

Since gl_UNKNOWN_WARNINGS_ARE_ERRORS is therefore language-dependent, that makes me think it needs to be called, not AC_REQUIREd, by gl_{CXX_,}_WARN_ADD (because the language might change each time), but if it were that simple, you'd've said so. So I'm not sure what else is needed…

​I attach the latest state of play, which consists simply of updated versions of manywarnings.m4 and warnings.m4, in place of the new files I had before. (To test them I have simply placed them in a gnulib patch directory which is applied by bootstrap; I love how simple it is!)


Attachment: manywarnings.m4
Description: application/m4

Attachment: warnings.m4
Description: application/m4

reply via email to

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