简体   繁体   English

C++:获取 MacOS 版本

[英]C++: Get MacOS version

I need to find a way to find the OS version of a MacOS system, preferably without external libraries.我需要找到一种方法来找到 MacOS 系统的 OS 版本,最好没有外部库。 How would that be possible?这怎么可能?

I don't have a MacOS machine to be able to test the code.我没有能够测试代码的 MacOS 机器。

Compiler: g++编译器:g++

The simplest solution is to do:最简单的解决方案是:

#include <sys/utsname.h>

void main() {
    struct utsname uts;
    uname(&uts);
    return uts.release;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM