在C ++中与平台无关的GUID生成? [英] Platform-independent GUID generation in C++?

查看:174
本文介绍了在C ++中与平台无关的GUID生成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中以编程方式生成GUID或UUID而不依赖于特定于平台的工具的最好方法是什么?我试图在模拟中为对象创建唯一标识符,但不能依赖Microsoft的实现,因为项目是跨平台的。

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 simulation, but can't rely on Microsoft's implementation as the project is cross-platform.

注意:


  • 由于这是一个模拟器,I
    不需要加密的
    随机性。

  • 最好是32位数。

推荐答案

如果您能负担得起使用Boost,则有一个 UUID 库应该可以做到。使用非常简单 - 请查看文档和此答案

If you can afford to use Boost, then there is a UUID library that should do the trick. It's very straightforward to use - check the documentation and this answer.

这篇关于在C ++中与平台无关的GUID生成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆