对于C UUID库? [英] UUID library for C?

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

问题描述

我正在寻找在C编程UUID库,有被安装(或至少通过安装包管理器)在大多数现代Linux桌面的合理可能性,并与章pkg-工作配置

I'm looking for a UUID library for programming in C, that has a reasonable probability of being installed (or at least installable by package manager) on most modern Linux desktops, and works with pkg-config.

以下两种可能性似乎最明显的:

The following two possibilities seem most obvious:

  • OSSP UUID
  • Libuuid from e2fsprogs

任何人是否有与这两个经验,可以推荐一个比其他,或第三方法可行?

Does anybody have experience with these two and can recommend one over the other, or a third possiblity?

推荐答案

我同时使用,而且我肯定preFER使用util-Linux的NG(原的e2fsprogs)之一。对于可移植性,使我的软件,同时支持和使用autoconf / cmake的宏来检测安装了哪一个。

I used both, and I definitely prefer the util-linux-ng (formerly in e2fsprogs) one. For portability, I make my software support both and use autoconf/cmake macros to detect which one is installed.

与OSSP的主要问题对我来说,它在滥用℃,没有很好的理由面向对象。一个UUID是仅有128位的数字,其可以被重新使用char [16]数组psented $ P $。该UUID通常与其它结构(UUID充当关键还是这样的结构的标识符)相关联,所以它应该是很好的,如果你能在内嵌结构本身。

The main problem with OSSP for me is that it abuses object-orientation in C for no good reason. An UUID is just a 128-bit number, which can be represented with a char[16] array. The UUID is usually associated with another structure (the UUID serves as a key or an identifier for such structure), so it should be good if you could inline that array in the structure itself.

使用OSSP UUID,它给你一个 uuid_t * 指针指向一个动态分配的对象,它拥有更多的国家不仅仅是UUID值。如果您使用对象数以万计的工作,这使得合理的程序慢,使用更多的内存,并导致更多的内存碎片。最终,使OSSP UUID可用,你必须使用它只是生成UUID(涉及4电话:uuid_create,uuid_make,uuid_export和uuid_destroy),并与UUID值自己工作。随着UTIL-Linux的NG,它仅仅是一个单一的电话:uuid_generate

With OSSP UUID, it gives you a uuid_t* pointer to a dynamically allocated object, which holds more state than just the UUID value. If you work with tens of thousands of objects, this sensibly makes the program slower, uses more memory and causes more memory fragmentation. In the end, to make OSSP UUID usable, you have to use it just to generate the UUID (which involves 4 calls: uuid_create, uuid_make, uuid_export and uuid_destroy) and work with the UUID value yourself. With util-linux-ng, it is just a single call: uuid_generate.

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

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