如何定义'_LIBCPP_VERSION'
How to define '_LIBCPP_VERSION'?
我发现一些库包括以下代码:
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
#define MSGPACK_HAS_STD_UNOURDERED_MAP
#include <unordered_map>
#define MSGPACK_STD_TR1 std
#else // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
#if __GNUC__ >= 4
#define MSGPACK_HAS_STD_TR1_UNOURDERED_MAP
#include <tr1/unordered_map>
#define MSGPACK_STD_TR1 std::tr1
#endif // __GNUC__ >= 4
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
我想知道如何/在哪里定义_LIBCPP_VERSION
和_MSC_VER
,它是否在使用默认的g++中自动检测?
如果我想使用g++-4.7.2怎么办?
_MSC_VER
是一个内置的Visual Studio定义。根据本文档,它将被设置为Visual Studio版本。
根据类似的文档,当您包含"一个标准头文件"时,会自动定义_LIBCPP_VERSION
。这看起来像是在使用libc++时定义的。
我还在你的代码中看到一个__GNUC__
检查。它将测试GCC或兼容GCC的编译器,如Clang。
让我们逐行分解代码:
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700) //Are we using libc++, or is MSVC installed and above a certain version?
//the next three lines set up defines and includes that libc++/MSVC can use
#define MSGPACK_HAS_STD_UNOURDERED_MAP
#include <unordered_map>
#define MSGPACK_STD_TR1 std
#else // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700) //MSVC isn't installed and we're not using libc++, so we'll need to check other compilers
#if __GNUC__ >= 4 //Are we running under GCC or a GCC-compliant compiler?
//the next three lines set up similar defines and includes to the libc++/MSVC ones from above, but these are GCC-based
#define MSGPACK_HAS_STD_TR1_UNOURDERED_MAP
#include <tr1/unordered_map>
#define MSGPACK_STD_TR1 std::tr1
#endif // __GNUC__ >= 4 //this ends the GCC test #if block
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700) //this ends the libc++/MSVC test #if block
相关文章:
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 为什么 -mmacosx-version-min=10.10 不阻止使用标记为从 10.11 开始的函数?
- C++ Version Of Double.longBitsToDouble
- 在 C++ 中嵌入 V8 会导致与 libcpp 相关的"unrecognized external symbol"错误
- Linux C++编程:为什么连接是.so,生成的可执行依赖库是.so.version
- QT "relocation error" / "no version information available"运行时错误
- 在 OpenGL 中在 Mac 上编译着色器时出现"version not supported"错误
- 使用 Boost ASIO 和 SSL 时出现"Wrong Version Number"错误 (C++)
- 由于错误'wrong version number'无法完成握手
- Windows 10 环境中的"This version of XAudio2 is available only in Windows 8"错误
- MAC OpenGL 着色器错误:"version '150' is not supported "
- opengl version from glxinfo
- cython内部分配libcpp.list
- 不使用系统Protobuf库时的"Protobuf compiler version doesn't match library version 3.6.1"
- SDL 2.0 version of SDL_DisplayFormatAlpha()?
- tesseract.lib (version 4 ) for windows 10 (x64)
- "Missing GL version" 从 glewInit() 使用 EGL?
- Visual Studio - 升级后"Unknown Compiler version"
- Softbank Pepper Development - 在Android Studio中使用Java SDK - java-naoqi-sdk-<version><platfor
- constexpr version of ::std::function