Menu

#6 Building with GCC-6 fails with `error: macro "min" passed 3 arguments, but takes just 2`

v1.0 (example)
open
nobody
None
5
2017-05-24
2017-05-21
Hodorgasm
No

Compiling squirrelsh-1.2.7 with GCC-6 fails with:

error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^

See: https://bugs.gentoo.org/show_bug.cgi?id=594466

In gcc-6, all <math.h> functions which were otherwise defined as macros, such as max() and min(), are now defined as real functions. In shell/base.cpp, by including "common.h", which defines such macros which conflict with <math.h> functions, before C++ standard headers, which transitively include <math.h>, the mismatch occurs. Including "common.h" after such headers resolves the issue.

1 Attachments

Discussion

  • Constantin Makshin

    Sorry for the late response.

    I went a bit further than you suggested and replaced all min() and max() macros with more appropriate std::min() and std::max() functions.

    See https://sourceforge.net/p/squirrelsh/git/ci/13280cdf34d96216b4d10b9ea7656a42a967fc2b/ for details.

     
    • Hodorgasm

      Hodorgasm - 2017-05-24

      That's the better way of handling it. Thanks.

       

Log in to post a comment.

MongoDB Logo MongoDB