Windows
检查编译器
_MSC_VER
- 预处理指令
- 用于检查是否正在使用
Microsoft Visual C++编译器,并根据编译器的类型或版本执行相应的代码
__cplusplus_winrt
- 预处理指令
- 用于根据正在编译的代码是否为 Windows 运行时组件执行不同的代码逻辑
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#if defined(_MSC_VER) # if defined(__cplusplus_winrt) return std::string{}; // not supported under uwp # else size_t len = 0; char buf[128]; bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0; return ok ? buf : std::string{}; # endif #else // revert to getenv char *buf = ::getenv(field); return buf ? buf : std::string{}; #endif |
声明:本文为原创文章,版权归Aet所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ C++14_第二篇06/29
- ♥ 深入理解C++11:C++11新特性解析与应用 一12/21
- ♥ Photoshop CEP扩展和插件开发04/27
- ♥ STL_priority_queue08/26
- ♥ 深入理解C++11:C++11新特性解析与应用 二12/30
- ♥ C++标准模板库编程实战_序列容器12/06