How to get platform IDs from boost?(如何从 boost 中获取平台 ID?)
问题描述
我们如何知道代码运行的是哪个操作系统?
How can we know which operating system the code is running?
例如如何了解Unix-Linux、Solaris、HP Unix、Windows、Mac等操作系统?
e.g. How to know the operating system like Unix-Linux, Solaris, HP Unix, Windows, Mac etc?
我们如何使用 boost 确定 C++ 代码中的操作系统?我想从 Boost v1.41 开始测试.
How can we determine operating system in C++ code with boost? I want to test with Boost v1.41 onwards.
推荐答案
快速扫描 version.hpp
/config.hpp
后发现:
These are things a quick scan of version.hpp
/config.hpp
revealed:
Live On Coliru强>
#include <boost/version.hpp>
#include <boost/config.hpp>
#include <iostream>
int main() {
std::cout << "BOOST_VERSION " << BOOST_VERSION << "
";
std::cout << "BOOST_LIB_VERSION " << BOOST_LIB_VERSION << "
";
std::cout << "BOOST_PLATFORM " << BOOST_PLATFORM << "
";
std::cout << "BOOST_PLATFORM_CONFIG " << BOOST_PLATFORM_CONFIG << "
";
std::cout << "BOOST_COMPILER " << BOOST_COMPILER << "
";
#ifdef BOOST_LIBSTDCXX_VERSION
std::cout << "BOOST_LIBSTDCXX_VERSION " << BOOST_LIBSTDCXX_VERSION << "
";
#endif
#ifdef BOOST_LIBSTDCXX11
std::cout << "Compiled with c++11 support enabled
";
#endif
std::cout << "BOOST_STDLIB " << BOOST_STDLIB << "
";
std::cout << "BOOST_STDLIB_CONFIG " << BOOST_STDLIB_CONFIG << "
";
}
打印出来的
BOOST_VERSION 106400
BOOST_LIB_VERSION 1_64
BOOST_PLATFORM linux
BOOST_PLATFORM_CONFIG boost/config/platform/linux.hpp
BOOST_COMPILER Clang version 3.8.0 (tags/RELEASE_380/final 263969)
BOOST_STDLIB libc++ version 1101
BOOST_STDLIB_CONFIG boost/config/stdlib/libcpp.hpp
或者在我自己的机器上
BOOST_VERSION 106500
BOOST_LIB_VERSION 1_65
BOOST_PLATFORM linux
BOOST_PLATFORM_CONFIG boost/config/platform/linux.hpp
BOOST_COMPILER GNU C++ version 7.2.0
BOOST_LIBSTDCXX_VERSION 70200
Compiled with c++11 support enabled
BOOST_STDLIB GNU libstdc++ version 20170818
BOOST_STDLIB_CONFIG boost/config/stdlib/libstdcpp3.hpp
这篇关于如何从 boost 中获取平台 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 boost 中获取平台 ID?


- 如何对自定义类的向量使用std::find()? 2022-11-07
- Stroustrup 的 Simple_window.h 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- C++ 协变模板 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 近似搜索的工作原理 2021-01-01