Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 新GSL是否与log4cpp不兼容?_C++_Visual Studio_Visual C++ - Fatal编程技术网

C++ 新GSL是否与log4cpp不兼容?

C++ 新GSL是否与log4cpp不兼容?,c++,visual-studio,visual-c++,C++,Visual Studio,Visual C++,如果我只包括GSL标题,一切都很好。如果我只包含log4cpp标题,那么一切都很好。但是如果我同时包括这两个,特别是log4cpfirst和GSL second,那么我会得到以下错误MSVC 2015: 3>c:\project\msvc\deps\source\gsl\include\string_view.h(82): warning C4003: not enough actual parameters for macro 'max' 3>c:\project\msvc\dep

如果我只包括GSL标题,一切都很好。如果我只包含log4cpp标题,那么一切都很好。但是如果我同时包括这两个,特别是log4cpfirst和GSL second,那么我会得到以下错误MSVC 2015:

3>c:\project\msvc\deps\source\gsl\include\string_view.h(82): warning C4003: not enough actual parameters for macro 'max'
3>c:\project\msvc\deps\source\gsl\include\string_view.h(82): error C2589: '(': illegal token on right side of '::'
3>c:\project\msvc\deps\source\gsl\include\string_view.h(82): error C2988: unrecognizable template declaration/definition
3>c:\project\msvc\deps\source\gsl\include\string_view.h(82): error C2059: syntax error: '::'
3>c:\project\msvc\deps\source\gsl\include\string_view.h(97): warning C4003: not enough actual parameters for macro 'max'
3>c:\project\msvc\deps\source\gsl\include\string_view.h(97): error C2589: '(': illegal token on right side of '::'
3>c:\project\msvc\deps\source\gsl\include\string_view.h(97): error C2988: unrecognizable template declaration/definition
3>c:\project\msvc\deps\source\gsl\include\string_view.h(97): error C2059: syntax error: '::'
有人知道为什么吗?下面是一个非常简单的项目:

CMakeLists.txt:

project(log4cpp_gsl_compat)

include(ExternalProject)
set_property(DIRECTORY PROPERTY EP_BASE "${CMAKE_CURRENT_BINARY_DIR}/deps")

ExternalProject_Add(gsl
    URL https://github.com/Microsoft/GSL/archive/3fd9f249da093ea1b73ec4135e9d8ad0b991d75b.tar.gz # rev 5 Oct 2015
    URL_HASH MD5=1fc79c1e548c500672ba9cb710d54471

    # Header-only library; there's nothing to configure, build or install
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
)

ExternalProject_Add(log4cpp
    URL http://skylineservers.dl.sourceforge.net/project/log4cpp/log4cpp-1.1.x%20%28new%29/log4cpp-1.1/log4cpp-1.1.1.tar.gz
    URL_HASH MD5=1e173df8ee97205f412ff84aa93b8fbe

    # Don't worry about building for now; just trying to get past a header compile error
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
)

add_executable(log4cpp_gsl_compat main.cpp)
set_property(TARGET log4cpp_gsl_compat PROPERTY CXX_STANDARD 14)

target_include_directories(log4cpp_gsl_compat PUBLIC
    "${CMAKE_CURRENT_BINARY_DIR}/deps/Source/gsl/include"
    "${CMAKE_CURRENT_BINARY_DIR}/deps/Source/log4cpp/include"
)
main.cpp:

#include <log4cpp/Category.hh>
#include <gsl.h>

int main(const int argc, const char* argv[])
{
    // ...

    return 0;
}

宏“max”的实际参数不足。有人疯狂地将max定义为一个宏。你说的GSL是指Gnu科学图书馆吗?@Galik他指的是。指南支持图书馆目前正在进行中,正在热开发中,每天甚至每小时都在变化。