Can't compile C++ project (macro “max” passed

2020-03-28 17:20发布

Sorry for the generic title, but I am no pro when it comes to C++ compiling and I can't seem to find the error here.

I am checking out an official project, so I know that thing should actually compile just fine. It doesn't.

If somebody wants to checkout the code themselves, here you go:

cvs -d :pserver:jvtuser:jvt.Amd.2@garcon.ient.rwth-aachen.de:/cvs/jvt login
cvs -d :pserver:jvtuser@garcon.ient.rwth-aachen.de:/cvs/jvt checkout jmvc
cd jmvc/JMVC/H264Extension/build/linux
make

When I call make, I receive:

make -C lib/H264AVCVideoIoLib release
make[1]: Entering directory `/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib'
g++ -c -MMD -MF ./objects/H264AVCVideoIoLib.r.d -MT ./objects/H264AVCVideoIoLib.r.o -fPIC -DMSYS_LINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DMSYS_UNIX_LARGEFILE  -I/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include -I../../../../src/lib/H264AVCVideoIoLib -DMERL_VIEW -Wall -Wshadow -Wno-reorder -Wno-sign-compare -O3 -ffloat-store -DNDEBUG -Wuninitialized -o objects/H264AVCVideoIoLib.r.o /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../src/lib/H264AVCVideoIoLib/H264AVCVideoIoLib.cpp
In file included from /usr/include/c++/4.4/bits/stl_algo.h:61,
                 from /usr/include/c++/4.4/algorithm:62,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCCommonIf.h:56,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCVideoIoLib.h:5,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../src/lib/H264AVCVideoIoLib/H264AVCVideoIoLib.cpp:2:
/usr/include/c++/4.4/bits/algorithmfwd.h:353: error: macro "max" passed 3 arguments, but takes just 2
/usr/include/c++/4.4/bits/algorithmfwd.h:364: error: macro "min" passed 3 arguments, but takes just 2
In file included from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemCont.h:9,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h:9,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCCommonIf.h:45,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCVideoIoLib.h:5,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../src/lib/H264AVCVideoIoLib/H264AVCVideoIoLib.cpp:2:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemAccessor.h: In member function ‘Void MemAccessList<T>::copyPayload(T*&, UInt&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemAccessor.h:207: error: ‘::memcpy’ has not been declared
In file included from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h:9,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCCommonIf.h:45,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCVideoIoLib.h:5,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../src/lib/H264AVCVideoIoLib/H264AVCVideoIoLib.cpp:2:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemCont.h: In copy constructor ‘MemCont<T>::MemCont(const MemCont<T>&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemCont.h:68: error: ‘::memcpy’ has not been declared
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemCont.h: In member function ‘MemCont<T>& MemCont<T>::operator=(const MemCont<T>&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemCont.h:113: error: ‘::memcpy’ has not been declared
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemCont.h: In member function ‘Void MemCont<T>::release(T*&, UInt&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemCont.h:221: error: ‘::memcpy’ has not been declared
In file included from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCCommonIf.h:45,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCVideoIoLib.h:5,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../src/lib/H264AVCVideoIoLib/H264AVCVideoIoLib.cpp:2:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h: In copy constructor ‘MemList<T>::MemList(const MemList<T>&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h:31: error: ‘::memcpy’ has not been declared
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h: In member function ‘MemList<T>& MemList<T>::operator=(const MemList<T>&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h:68: error: ‘::memcpy’ has not been declared
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h: In member function ‘Void MemList<T>::release(T*&, UInt&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h:129: error: ‘::memcpy’ has not been declared
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h:151: error: ‘::memcpy’ has not been declared
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h: In member function ‘Void MemList<T>::release(T*&, UInt&, T*&, UInt&)’:
/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/MemList.h:181: error: ‘::memcpy’ has not been declared
In file included from /usr/include/c++/4.4/bits/stl_algo.h:61,
                 from /usr/include/c++/4.4/algorithm:62,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCCommonIf.h:56,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCVideoIoLib.h:5,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../src/lib/H264AVCVideoIoLib/H264AVCVideoIoLib.cpp:2:
/usr/include/c++/4.4/bits/algorithmfwd.h: At global scope:
/usr/include/c++/4.4/bits/algorithmfwd.h:349: error: expected unqualified-id before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:349: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:349: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:349: error: expected initializer before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:353: error: template declaration of ‘const _Tp& std::max’
/usr/include/c++/4.4/bits/algorithmfwd.h:360: error: expected unqualified-id before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:360: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:360: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:360: error: expected initializer before ‘const’
/usr/include/c++/4.4/bits/algorithmfwd.h:364: error: template declaration of ‘const _Tp& std::min’
In file included from /usr/include/c++/4.4/algorithm:62,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCCommonIf.h:56,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../include/H264AVCVideoIoLib.h:5,
                 from /home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib/../../../../src/lib/H264AVCVideoIoLib/H264AVCVideoIoLib.cpp:2:
/usr/include/c++/4.4/bits/stl_algo.h: In function ‘void std::__merge_sort_loop(_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _Distance)’:
/usr/include/c++/4.4/bits/stl_algo.h:3239: error: expected unqualified-id before ‘(’ token
/usr/include/c++/4.4/bits/stl_algo.h: In function ‘void std::__merge_sort_loop(_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _Distance, _Compare)’:
/usr/include/c++/4.4/bits/stl_algo.h:3263: error: expected unqualified-id before ‘(’ token
make[1]: *** [objects/H264AVCVideoIoLib.r.o] Error 1
make[1]: Leaving directory `/home/user/JMVC/jmvc/JMVC/H264Extension/build/linux/lib/H264AVCVideoIoLib'
make: *** [release] Error 2

Just fyi, I'm using g++:

Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)

... and gcc:

Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) 

I'd be very thankful if somebody had some pointers...

2条回答
手持菜刀,她持情操
2楼-- · 2020-03-28 18:00

C++'s standard library does not use or define max or min as macros. The line where the first error is reported (/usr/include/c++/4.4/bits/algorithmfwd.h:353) contains a forward declaration for the std::max template function with a third parameter. From what I can see in the infos you gave, I'd reckon that on your system some old header is included, which defines max() and min() as macros. A common problem, by the way.

You'll need to identify the header (or source file) which defines max/min and try to figure out if there is a way to configure the source code to build without that header.

UPDATE: Looks like the culprits are in the source files:

> grep -R "#define min" *
include/DownConvertTools.inl:#define min(x, y) ((x)<(y)?(x):(y))
include/H264AVCCommonLib/GlobalFunctions.h:#define min(x,y) ((x)<(y)?(x):(y))
include/H264AVCCommonIf.h:#define min(x,y) ((x)<(y)?(x):(y))
src/test/H264AVCDecoderLibTest/DecoderParameter.h:#define min(x,y) (((x) < (y)) ? (x) : (y))
src/lib/H264AVCCommonLib/CFMO.cpp://#define min(a,b) ((a)>(b))?b:a

Duplicated definitions usually mean that the code needs cleanup anyway, so you could start by removing the macros and replacing max/min with std::max/std::min.

查看更多
聊天终结者
3楼-- · 2020-03-28 18:00

The ddraw.lib is actually not used by the software, so you can safely remove ddraw.lib from the list of libraries linker used and the solution will build successfully.

查看更多
登录 后发表回答