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::cin 读取密码 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01