Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC 6 error: macro "min" passed 3 arguments, but takes just 2 #21

Open
hfs opened this issue Oct 25, 2017 · 2 comments · May be fixed by #22
Open

GCC 6 error: macro "min" passed 3 arguments, but takes just 2 #21

hfs opened this issue Oct 25, 2017 · 2 comments · May be fixed by #22

Comments

@hfs
Copy link

hfs commented Oct 25, 2017

FYBA fails to compile with GCC 6:

make[2]: Entering directory '/home/user/Downloads/fyba/src/FYBA'
/bin/bash ../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../..  --pedantic -Wno-long-long -Wall -O2 -D_FILE_OFFSET_BITS=64 -DUNIX -DLINUX -fPIC -Wno-write-strings -I../GM -I../UT   -g -O2 -MT FYLU.lo -MD -MP -MF .deps/FYLU.Tpo -c -o FYLU.lo FYLU.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../.. --pedantic -Wno-long-long -Wall -O2 -D_FILE_OFFSET_BITS=64 -DUNIX -DLINUX -fPIC -Wno-write-strings -I../GM -I../UT -g -O2 -MT FYLU.lo -MD -MP -MF .deps/FYLU.Tpo -c FYLU.cpp  -fPIC -DPIC -o .libs/FYLU.o
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/locale:39,
                 from FYLU.cpp:11:
/usr/include/c++/6/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
/usr/include/c++/6/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
In file included from stdafx.h:12:0,
                 from FYLU.cpp:7:
/usr/include/c++/6/bits/stl_algobase.h:195:5: error: expected unqualified-id before ‘const’
     min(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/6/bits/stl_algobase.h:195:5: error: expected ‘)’ before ‘const’
/usr/include/c++/6/bits/stl_algobase.h:195:5: error: expected ‘)’ before ‘const’
/usr/include/c++/6/bits/stl_algobase.h:195:5: error: expected ‘)’ before ‘const’
/usr/include/c++/6/bits/stl_algobase.h:195:5: error: expected initializer before ‘const’
/usr/include/c++/6/bits/stl_algobase.h:219:5: error: expected unqualified-id before ‘const’
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/6/bits/stl_algobase.h:219:5: error: expected ‘)’ before ‘const’
/usr/include/c++/6/bits/stl_algobase.h:219:5: error: expected ‘)’ before ‘const’
/usr/include/c++/6/bits/stl_algobase.h:219:5: error: expected ‘)’ before ‘const’
/usr/include/c++/6/bits/stl_algobase.h:219:5: error: expected initializer before ‘const’
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/locale:39,
                 from FYLU.cpp:11:
/usr/include/c++/6/bits/stl_algobase.h:243:5: error: ‘std::min’ declared as an ‘inline’ variable
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:246:7: error: expected primary-expression before ‘if’
       if (__comp(__b, __a))
       ^~
/usr/include/c++/6/bits/stl_algobase.h:246:7: error: expected ‘}’ before ‘if’
/usr/include/c++/6/bits/stl_algobase.h:246:7: error: expected ‘;’ before ‘if’
/usr/include/c++/6/bits/stl_algobase.h:248:7: error: expected unqualified-id before ‘return’
       return __a;
       ^~~~~~
/usr/include/c++/6/bits/stl_algobase.h:265:5: error: ‘max’ declared as an ‘inline’ variable
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:268:7: error: expected primary-expression before ‘if’
       if (__comp(__a, __b))
       ^~
/usr/include/c++/6/bits/stl_algobase.h:268:7: error: expected ‘}’ before ‘if’
/usr/include/c++/6/bits/stl_algobase.h:268:7: error: expected ‘;’ before ‘if’
/usr/include/c++/6/bits/stl_algobase.h:270:7: error: expected unqualified-id before ‘return’
       return __a;
       ^~~~~~
/usr/include/c++/6/bits/stl_algobase.h:271:5: error: expected declaration before ‘}’ token
     }
     ^
Makefile:472: recipe for target 'FYLU.lo' failed
make[2]: *** [FYLU.lo] Error 1
make[2]: Leaving directory '/home/user/Downloads/fyba/src/FYBA'
Makefile:457: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/user/Downloads/fyba'
Makefile:366: recipe for target 'all' failed
make: *** [all] Error 2

As a temporary fix you can move #include "stdafx.h" below the other includes in src/FYBA/FYLU.cpp.

My g++ and libstdc++-6-dev version is 6.3.0-12ubuntu2 on Ubuntu zesty.

@adamjstewart
Copy link

I ran into the same problem with GCC 6.1.0 on CentOS 6.9. Your temporary fix worked perfectly!

petterreinholdtsen added a commit to petterreinholdtsen/fyba that referenced this issue Oct 26, 2019
This avoid conflicting definitions of max() and min().

Fixes kartverket#21

The patch was fetched from Gnonthgol@005e527 .
@sickel
Copy link

sickel commented Aug 19, 2024

Tried compiling on rocky linux 9, gcc 11.4.1, The mentioned fix does not help, so I am not able to compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants