Can't compile C++ project (macro “max” passed 3 arguments, but takes just 2)

后端 未结 2 1869
时光说笑
时光说笑 2021-01-14 21:30

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 kno

相关标签:
2条回答
  • 2021-01-14 22:05

    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.

    0 讨论(0)
  • 2021-01-14 22:13

    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.

    0 讨论(0)
提交回复
热议问题