---
name: "hwlocality_object_strings"
section: "3"
platform: "linux"
package: "hwloc"
version: "2.15.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_object_strings"
---

# hwlocality\_object\_strings(3)

Converting between Object Types and Attributes, and Strings

## NAME

hwlocality\_object\_strings - Converting between Object Types and Attributes, and Strings

## SYNOPSIS

### Functions

const char \* **hwloc\_obj\_type\_string** (**hwloc\_obj\_type\_t** type)\
 int **hwloc\_obj\_type\_snprintf** (char \*restrict string, size\_t size, **hwloc\_obj\_t** obj, int verbose)\
 int **hwloc\_obj\_attr\_snprintf** (char \*restrict string, size\_t size, **hwloc\_obj\_t** obj, const char \*restrict separator, int verbose)\
 int **hwloc\_type\_sscanf** (const char \*string, **hwloc\_obj\_type\_t** \*typep, union **hwloc\_obj\_attr\_u** \*attrp, size\_t attrsize)\
 int **hwloc\_type\_sscanf\_as\_depth** (const char \*string, **hwloc\_obj\_type\_t** \*typep, **hwloc\_topology\_t** topology, int \*depthp)\

## Detailed Description

## Function Documentation

### int hwloc\_obj\_attr\_snprintf (char \*restrict string, size\_t size, hwloc\_obj\_t obj, const char \*restrict separator, int verbose)

Stringify the attributes of a given topology object into a human-readable form. Attribute values are separated by separator.

Only the major attributes are printed in non-verbose mode.

If size is 0, string may safely be NULL.

**Returns**

the number of characters that were actually written if not truncating, or that would have been written (not including the ending \\0).

### int hwloc\_obj\_type\_snprintf (char \*restrict string, size\_t size, hwloc\_obj\_t obj, int verbose)

Stringify the type of a given topology object into a human-readable form. Contrary to **hwloc\_obj\_type\_string()**, this function includes object-specific attributes (such as the Group depth, the Bridge type, or OS device type) in the output, and it requires the caller to provide the output buffer.

The output is guaranteed to be the same for all objects of a same topology level.

If verbose is 1, longer type names are used, e.g. L1Cache instead of L1.

The output string may be parsed back by **hwloc\_type\_sscanf()**.

If size is 0, string may safely be NULL.

**Returns**

the number of characters that were actually written if not truncating, or that would have been written (not including the ending \\0).

### const char \* hwloc\_obj\_type\_string (hwloc\_obj\_type\_t type)

Return a constant stringified object type. This function is the basic way to convert a generic type into a string. The output string may be parsed back by **hwloc\_type\_sscanf()**.

**hwloc\_obj\_type\_snprintf()** may return a more precise output for a specific object, but it requires the caller to provide the output buffer.

**Returns**

A constant string containing the object type name or "Unknown".

### int hwloc\_type\_sscanf (const char \* string, hwloc\_obj\_type\_t \* typep, union hwloc\_obj\_attr\_u \* attrp, size\_t attrsize)

Return an object type and attributes from a type string. Convert strings such as "Package" or "L1iCache" into the corresponding types. Matching is case-insensitive, and only the first letters are actually required to match.

The matched object type is set in typep (which cannot be NULL).

Type-specific attributes, for instance Cache type, Cache depth, Group depth, Bridge type or OS Device type may be returned in attrp. Attributes that are not specified in the string (for instance "Group" without a depth, or "L2Cache" without a cache type) are set to -1.

attrp is only filled if not NULL and if its size specified in attrsize is large enough. It should be at least as large as union **hwloc\_obj\_attr\_u**.

**Returns**

0 if a type was correctly identified, otherwise -1.

**Note**

This function is guaranteed to match any string returned by **hwloc\_obj\_type\_string()** or **hwloc\_obj\_type\_snprintf()**.

This is an extended version of the now deprecated hwloc\_obj\_type\_sscanf().

### int hwloc\_type\_sscanf\_as\_depth (const char \* string, hwloc\_obj\_type\_t \* typep, hwloc\_topology\_t topology, int \* depthp)

Return an object type and its level depth from a type string. Convert strings such as "Package" or "L1iCache" into the corresponding types and return in depthp the depth of the corresponding level in the topology topology.

If no object of this type is present on the underlying architecture, **HWLOC\_TYPE\_DEPTH\_UNKNOWN** is returned.

If multiple such levels exist (for instance if giving Group without any depth), the function may return **HWLOC\_TYPE\_DEPTH\_MULTIPLE** instead.

The matched object type is set in typep if typep is non NULL.

**Note**

This function is similar to **hwloc\_type\_sscanf()** followed by **hwloc\_get\_type\_depth()** but it also automatically disambiguates multiple group levels etc.

This function is guaranteed to match any string returned by **hwloc\_obj\_type\_string()** or **hwloc\_obj\_type\_snprintf()**.

## Author

Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code.
