cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
platforms.hpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CPP_VERSION_STR(year, month)   #year #month "L"
 编译器检测宏 / Compiler detection macros
 
#define CPP_VERSION_TO_INT(year, month)   year##month##L
 将C++版本转换为整数 / Convert C++ version to integer
 
#define CPP_11   CPP_VERSION_TO_INT(201, 103)
 C++标准检测 / C++ standard detection.
 
#define CPP_14   CPP_VERSION_TO_INT(201, 402)
 
#define CPP_17   CPP_VERSION_TO_INT(201, 703)
 
#define CPP_20   CPP_VERSION_TO_INT(202, 002)
 
#define CPP_TOOLBOX_CXX_LARGE_THAN_17(Content)    static_assert(__cplusplus >= CPP_17, Content)
 C++17要求的静态断言 / Static assert for C++17 requirement.
 
#define CPP_TOOLBOX_CXX_VERSION   get_cpp_version()
 获取C++版本字符串 / Get C++ version string
 

Functions

constexpr const char * get_cpp_version ()
 获取C++版本字符串 / Get C++ version as string
 

Macro Definition Documentation

◆ CPP_11

#define CPP_11   CPP_VERSION_TO_INT(201, 103)

C++标准检测 / C++ standard detection.

C++版本宏定义 / C++ version macros

◆ CPP_14

#define CPP_14   CPP_VERSION_TO_INT(201, 402)

◆ CPP_17

#define CPP_17   CPP_VERSION_TO_INT(201, 703)

◆ CPP_20

#define CPP_20   CPP_VERSION_TO_INT(202, 002)

◆ CPP_TOOLBOX_CXX_LARGE_THAN_17

#define CPP_TOOLBOX_CXX_LARGE_THAN_17 (   Content)     static_assert(__cplusplus >= CPP_17, Content)

C++17要求的静态断言 / Static assert for C++17 requirement.

Parameters
Content断言消息 / Assert message
CPP_TOOLBOX_CXX_LARGE_THAN_17("This feature requires C++17 or later");
#define CPP_TOOLBOX_CXX_LARGE_THAN_17(Content)
C++17要求的静态断言 / Static assert for C++17 requirement.
Definition platforms.hpp:154

◆ CPP_TOOLBOX_CXX_VERSION

#define CPP_TOOLBOX_CXX_VERSION   get_cpp_version()

获取C++版本字符串 / Get C++ version string

◆ CPP_VERSION_STR

#define CPP_VERSION_STR (   year,
  month 
)    #year #month "L"

编译器检测宏 / Compiler detection macros

用于检测当前使用的编译器类型 / Used to detect the current compiler type:

  • MSVC: Microsoft Visual C++ 编译器 / Microsoft Visual C++ Compiler
  • Clang: LLVM Clang 编译器 / LLVM Clang Compiler
  • GCC: GNU C++ 编译器 / GNU C++ Compiler

平台检测宏 / Platform detection macros

用于检测当前运行平台 / Used to detect the current platform:

  • Windows: Windows 操作系统 / Windows Operating System
  • Linux: Linux 操作系统 / Linux Operating System
  • macOS: Apple macOS 操作系统 / Apple macOS Operating System
  • FreeBSD: FreeBSD 操作系统 / FreeBSD Operating System
  • NetBSD: NetBSD 操作系统 / NetBSD Operating System
  • Android: Android 操作系统 / Android Operating System
  • QNX: QNX 实时操作系统 / QNX Real-time Operating System

架构检测宏 / Architecture detection macros

用于检测当前CPU架构 / Used to detect the current CPU architecture:

  • x86_64: 64位x86架构 / 64-bit x86 architecture
  • x86: 32位x86架构 / 32-bit x86 architecture
  • ARM64: 64位ARM架构 / 64-bit ARM architecture
  • ARM: 32位ARM架构 / 32-bit ARM architecture
  • RISC-V: RISC-V架构 / RISC-V architecture
  • LoongArch: 龙芯架构 / LoongArch architecture

将C++版本转换为字符串 / Convert C++ version to string

Parameters
year版本号中的年份部分 / Year part of version number
month版本号中的月份部分 / Month part of version number
Returns
版本的字符串表示 / String representation of version
// 将C++17版本号转换为字符串
// Convert C++17 version to string
const char* version = CPP_VERSION_STR(201, 703);
std::cout << version << std::endl; // 输出: "201703L" / Outputs: "201703L"
#define CPP_VERSION_STR(year, month)
编译器检测宏 / Compiler detection macros
Definition platforms.hpp:89

◆ CPP_VERSION_TO_INT

#define CPP_VERSION_TO_INT (   year,
  month 
)    year##month##L

将C++版本转换为整数 / Convert C++ version to integer

Parameters
year版本号中的年份部分 / Year part of version number
month版本号中的月份部分 / Month part of version number
Returns
版本的整数表示 / Integer representation of version
// 将C++17版本号转换为整数
// Convert C++17 version to integer
constexpr auto version = CPP_VERSION_TO_INT(201, 703);
static_assert(version == 201703L);
#define CPP_VERSION_TO_INT(year, month)
将C++版本转换为整数 / Convert C++ version to integer
Definition platforms.hpp:104

Function Documentation

◆ get_cpp_version()

constexpr const char * get_cpp_version ( )
constexpr

获取C++版本字符串 / Get C++ version as string

Returns
C++版本的字符串表示 / String representation of C++ version
const char* version = get_cpp_version();
std::cout << "Using " << version << std::endl; // 输出当前C++版本 / Outputs
current C++ version
constexpr const char * get_cpp_version()
获取C++版本字符串 / Get C++ version as string
Definition platforms.hpp:131