autoconf
[Top][All Lists]
Advanced

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

Re: best way to check for compiler _warnings_?


From: Miles Bader
Subject: Re: best way to check for compiler _warnings_?
Date: Tue, 2 Nov 2010 16:18:24 +0900

On Tue, Nov 2, 2010 at 4:04 PM, Peter Rosin <address@hidden> wrote:
> Den 2010-11-02 06:46 skrev Ralf Wildenhues:
>> Except then you may run into MSVC which prints its command-line options
>> (dunno whether on stdout or stderr) ...
>
> To expand on that tangent...
>
> MSVC "only" prints the options it ends up feeding to link.exe (or maybe
> it's link.exe that prints them?) and only if the -nologo option isn't
> specified.  On stdout.  Unknown options are reported on stderr (with
> zero exit status, of course).

Yeah, this is what I tried, which seems to work OK:

      ... junk omitted ...
      CXXFLAGS="$CXXFLAGS $OPT"
      AC_MSG_CHECKING(whether C++ compiler accepts "$OPT" option)
      AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]),
        [opt_ok=yes
         if test -s conftest.err; then
           for ONE_OPT in $OPT; do
             if grep -e "$ONE_OPT" conftest.err >/dev/null; then
               opt_ok=no
               break
             fi
           done
         fi],
        [opt_ok=no])
      AC_MSG_RESULT([$opt_ok])

Where OPT holds the option being checked (it can contain multiple
options, and the warning message may only mention one of them, thus
the loop).

-miles

-- 
Cat is power.  Cat is peace.



reply via email to

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