用C GUID简单的代 [英] Simple Generation of GUID in C

查看:99
本文介绍了用C GUID简单的代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得像GUID / UUID问题已经做死在这里,但我似乎无法找到完全是我要找的。我需要一个函数,将生成用C V4的GUID,即东西,本质上是与compatibile从Guid.NewGuid C#。

I feel like GUID/UUID questions have been done to death here, but I can't seem to find quite what I'm looking for. I need a function that will generate V4 GUIDs in C, i.e. something that is essentially compatibile with Guid.NewGuid from C#.

这已经在Windows(XP,服务器第2003/8号等)和Unix的3种不同的发行版(AIX,Sun和HP)工作。

This has to work on Windows (XP, Server 2003/8, etc) and 3 different distros of Unix (AIX, Sun, and HP).

我已经看到了一些规范白皮书,一些甚至有一些示例实现,但似乎总是有适当的随机数的问题,或者他们只产生V1或V3的UUID,等的为UUID的维基百科页面指着我在一对夫妇的样本库,但这些手法过重的重量为我M想在这里完成的。

I've seen some of the specification white papers, some that even have some sample implementations, but there always seems to be an issue with proper random numbers, or they only generate V1 or V3 UUIDs, etc. The wikipedia page for UUIDs pointed me at a couple of sample libraries, but these are WAY too heavy weight for what I'm trying to accomplish here.

我觉得pretty坚信我可以实现自己的东西,但不想浪费时间重新发明轮子,如果有很简单的东西,重量轻我可以顺路去。任何人有什么或不知道的东西吗?

I feel pretty strongly that I could implement something myself, but don't want to waste time reinventing the wheel if there is something really simple and lightweight I could just drop in. Anybody have something or know of something?

感谢。

推荐答案

CoCreateGuid 是对各种形式的Windows标准。 Linux的标准是 libuuid ,这是所有Linux版本的标准,应该是轻量级的。我不知道,这将适用于Windows和UNIX工作的图书馆。我认为,一个#如果枝Windows和Linux实际上是适当的在这里。

CoCreateGuid is standard for all forms of Windows. Linux standard is libuuid, which is standard on all Linux versions and should be lightweight. I don't know of any library that will work for both Windows and Unix. I think that an #if branch for Windows and Linux is actually appropriate here.

这篇关于用C GUID简单的代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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