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所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ Protobuf记述与使用01/24
- ♥ Soui应用 动画二06/27
- ♥ 深度探索C++对象模型:对象、构造、数据、函数、执行09/10
- ♥ Linux_进程地址空间相关03/29
- ♥ Photoshop CEP扩展和插件开发04/27
- ♥ 51CTO:Linux C++网络编程四08/19