Keywords: UE4, OpenCV

error C4002 too many arguments for function-like macro invocation ‘check’

Error 1st at building project:

D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(45): error C4002: too many arguments for function-like macro invocation 'check'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(45): error C2988: unrecognizable template declaration/definition
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(58): note: see reference to class template instantiation 'cv::sfinae::has_parenthesis_operator<C,Ret,Args...>' being compiled
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(45): error C2059: syntax error: '<end Parse>'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(45): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(47): error C2988: unrecognizable template declaration/definition
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(47): error C2059: syntax error: '<end Parse>'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2\core\cvstd_wrapper.hpp(47): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/types.hpp(2419): warning C4946: reinterpret_cast used between related classes: 'cv::Matx<double,4,1>' and 'cv::Scalar_<double>'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/matx.hpp(226): note: see declaration of 'cv::Matx<double,4,1>'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/types.hpp(669): note: see declaration of 'cv::Scalar_<double>'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/utility.hpp(53): fatal error C1021: invalid preprocessor command 'warning'

Error 2nd at building project:

D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/utility.hpp(977): error C4003: not enough arguments for function-like macro invocation 'check'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/utility.hpp(977): error C4003: not enough arguments for function-like macro invocation 'UE_CHECK_IMPL'
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/utility.hpp(977): error C2062: type 'bool' unexpected
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/utility.hpp(977): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/utility.hpp(977): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
D:\MyProj\ThirdParty\OpenCV\Includes\opencv2/core/utility.hpp(977): error C2208: 'const int': no members defined using this type

Caused by:
Third party libiary contains function check(), it would be shadowed by a macro check named as UE_CHECK_IMPL which implemented in UE4.

Solution 1st (Recommended):
If you have .o files there, a good solution:

#to rename the symbols in .o file
objcopy --prefix-symbols=pre_string test.o

or

#to rename the specific symbol in .o file.
objcopy --redefine-sym old_str=new_str test.o

Origin:
https://stackoverflow.com/a/41375697/1645289

Solution 2nd:
Rename the function check() in third party library source and rebuild it.

typedef redefinition with different types (’long’ vs ‘FPlatformTypes::int64’)

I had to change “opencv2/core/types_c.h”.
I changed the code below:

#else
    typedef int64_t int64;
    typedef uint64_t uint64;
    #define CV_BIG_INT(n)   n##LL
    #define CV_BIG_UINT(n)  n##ULL
#endif

By the the following code:

#else
    typedef long long int64;
    typedef unsigned long long uint64;
    #define CV_BIG_INT(n)   n##LL
    #define CV_BIG_UINT(n)  n##ULL
#endif

Reference: OpenCV compatible definition of int64
https://answers.unrealengine.com/questions/530971/opencv-compatible-definition-of-int64.html


“...time was not passing...it was turning in a circle..." ― Gabriel García Márquez, One Hundred Years of Solitude