---
name: "uuid_create"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/uuid/3"
---

# uuid\_create(3)

DCE 1.1 compliant UUID functions

Part of [uuid(3)](/uuid/3.md).

## NAME

**uuid\_compare**, **uuid\_create**, **uuid\_create\_nil**, **uuid\_equal**, **uuid\_from\_string**, **uuid\_hash**, **uuid\_is\_nil**, **uuid\_to\_string** – DCE 1.1 compliant UUID functions

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<uuid.h\>**

*int32\_t*\

**uuid\_compare**(*const uuid\_t \*uuid1*, *const uuid\_t \*uuid2*, *uint32\_t \*status*);

*void*\

**uuid\_create**(*uuid\_t \*uuid*, *uint32\_t \*status*);

*void*\

**uuid\_create\_nil**(*uuid\_t \*uuid*, *uint32\_t \*status*);

*int32\_t*\

**uuid\_equal**(*const uuid\_t \*uuid1*, *const uuid\_t \*uuid2*, *uint32\_t \*status*);

*void*\

**uuid\_from\_string**(*const char \*str*, *uuid\_t \*uuid*, *uint32\_t \*status*);

*uint16\_t*\

**uuid\_hash**(*const uuid\_t \*uuid*, *uint32\_t \*status*);

*int32\_t*\

**uuid\_is\_nil**(*const uuid\_t \*uuid*, *uint32\_t \*status*);

*void*\

**uuid\_to\_string**(*const uuid\_t \*uuid*, *char \*\*str*, *uint32\_t \*status*);

*void*\

**uuid\_enc\_le**(*void \*buf*, *const uuid\_t \*uuid*);

*void*\

**uuid\_dec\_le**(*const void \*buf*, *uuid\_t \**);

*void*\

**uuid\_enc\_be**(*void \*buf*, *const uuid\_t \*uuid*);

*void*\

**uuid\_dec\_be**(*const void \*buf*, *uuid\_t \**);

## DESCRIPTION

The family of DCE 1.1 compliant UUID functions allow applications to operate on universally unique identifiers, or UUIDs. The **uuid\_create**() and **uuid\_create\_nil**() functions create UUIDs. To convert from the binary representation to the string representation or vice versa, use **uuid\_to\_string**() or **uuid\_from\_string**() respectively.

The **uuid\_to\_string**() function set *\*str* to be a pointer to a buffer sufficiently large to hold the string. This pointer should be passed to [free(3)](/free/3.md) to release the allocated storage when it is no longer needed.

The **uuid\_enc\_le**() and **uuid\_enc\_be**() functions encode a binary representation of a UUID into an octet stream in little-endian and big-endian byte-order, respectively. The destination buffer must be pre-allocated by the caller, and must be large enough to hold the 16-octet binary UUID. These routines are not part of the DCE RPC API. They are provided for convenience.

The **uuid\_dec\_le**() and **uuid\_dec\_be**() functions decode a UUID from an octet stream in little-endian and big-endian byte-order, respectively. These routines are not part of the DCE RPC API. They are provided for convenience.

The **uuid\_compare**() and **uuid\_equal**() functions compare two UUIDs for equality. UUIDs are equal if pointers *a* and *b* are equal or both NULL, or if the structures *a* and *b* point to are equal. **uuid\_compare**() returns 0 if the UUIDs are equal, -1 if *a* is less than *b*, and 1 if *a* is greater than *b*. **uuid\_equal**() returns 1 if the UUIDs are equal, 0 if they are not equal.

The **uuid\_is\_nil**() function compares a UUID to NULL. The function returns 1 if *u* is NULL or if the UUID consists of all zeros, and zero otherwise.

The **uuid\_hash**() function returns a 16-bit hash value for the specified UUID.

## RETURN VALUES

The successful or unsuccessful completion of the function is returned in the *status* argument. Possible values are:

- uuid\_s\_ok

  The function completed successfully.

- uuid\_s\_bad\_version

  The UUID does not have a known version.

- uuid\_s\_invalid\_string\_uuid

  The string representation of an UUID is not valid.

- uuid\_s\_no\_memory

  The function can not allocate memory to store an UUID representation.

**uuid\_compare**(), **uuid\_equal**(), **uuid\_is\_nil**(), and **uuid\_hash**() always set *status* to uuid\_s\_ok.

## SEE ALSO

[uuidgen(1)](/uuidgen/1.md), [uuidgen(2)](/uuidgen/2.md)

## STANDARDS

The UUID functions conform to the DCE 1.1 RPC specification.

## BUGS

This manpage can be improved.
