C++ 系统调用 操作系统平台类型 跨平台
#pragma once
#include
#include
namespace cutl
{
/**
* @brief Operating system platform type.
*
*/
enum class os_platform
{
/** Windows */
os_windows,
/** macOS */
os_macos,
/** Linux */
os_linux,
/** Unix */
os_unix,
/** Unknown */
os_unknown,
};
/**
* @brief Get the platform type for the current operating system.
*
* @return platform The operating system platform type.
*/
os_platform platform_type();
/**
* @brief Get the platform name for the current operating system.
*
* @param type the operating system platform type.
*
* @return std::string the platform name.
*/
std::string platform_name(os_platform type);
} // namespace cutl
#include
#include "common.hpp"
#include "sysutil.h"
void TestPlatformName()
{
PrintSubTitle("TestPlatformName");
auto type = cutl::platform_type();
std::cout << "OS platform: " << cutl::platform_name(type) << std::endl;
}
------------------------------------------TestPlatformName------------------------------------------
OS platform: macOS
更多详细代码,请查看本人写的C++ 通用工具库: common_util, 本项目已开源,代码简洁,且有详细的文档和Demo。
本文由博客一文多发平台 OpenWrite 发布!