[Top][All Lists]

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

Re: Cross-platform "warning is an error" with Autoconf?

From: Peter Johansson
Subject: Re: Cross-platform "warning is an error" with Autoconf?
Date: Sat, 4 Aug 2018 15:04:17 +1000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Hi Jeff,

On 8/3/2018 9:38 AM, Jeffrey Walton wrote:
I'm having trouble crafting an Autotools test. I'm trying to test for
the availability of Micrsoft's init_seg():

    ## This needs to be cross-platform, and not MSC specific
    XXX_PROGRAM="#include <string>
       struct Bar {
          Bar(int x) : m_x(x) {}
          Bar(const Bar& o) : m_x(o.m_x) {}
          Bar& operator=(const Bar& o) {m_x=o.m_x; return *this;}
          static int s_x;
          int m_x;
       #pragma init_seg(".CRT$XCU")
       int Bar::s_x = -1;
       // This should be in a separate source file violating init order.
       // The problem is, we don't know how to do it with Autotools.
       Bar f = Bar::s_x;"

The problem is, Clang, GCC, XLC, SunCC, etc issue a warning for an
unknown pragma. Detecting the warning is part of the test we need.

If I change to CXXFLAGS="-Werror" then MSC and other Windows compilers
incorrectly reject the program.

I think the root cause of the problem is, I need a cross-platform way
to say "treat warnings as error". But I don't see an
AC_WARNINGS_AS_ERRORS or similar in Autoconf.

There is an AC_LANG_WERROR, but not sure how cross-platform it is. Hopefully it parses stderror rather relying on compiler switches such as -Werror. IIRC, it worked for me when I used it, but I think one problem was that there was no way to turn off this "warnings are errors"-behaviour.


reply via email to

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