Platform-independent GUID generation in C++?

后端 未结 6 1483
余生分开走
余生分开走 2020-12-02 10:27

What is the best way to programmatically generate a GUID or UUID in C++ without relying on a platform-specific tool? I am trying to make unique identifiers for objects in a

6条回答
  •  盖世英雄少女心
    2020-12-02 11:09

    If you cannot afford to use Boost, then there is a very minimal library that I implemented which simply acts as a wrapper around each operating system's native guid implementation. It should work on Windows (using CoCreateGuid), Linux (using libuuid), MacOS (using CFUUID), iOS (also using CFUUID), and Android (using JNI calls to java.util.UUID). The guid generation function has a different implementation on each system but there is single generic implementation for comparing, stringifying, and parsing.

    It is MIT licensed and available on GitHub:

    https://github.com/graeme-hill/crossguid

提交回复
热议问题