Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2026-07-28 The HDF5 Field Guide

Loading...
Searching...
No Matches
Compound Datatypes
Datatypes (H5T) » Compound and Enumeration Datatypes

## Detailed Description

## Functions
H5T_class_t | H5Tget_member_class (hid_t type_id, unsigned membno)
| Returns datatype class of compound datatype member.
size_t | H5Tget_member_offset (hid_t type_id, unsigned membno)
| Retrieves the offset of a field of a compound datatype.
hid_t | H5Tget_member_type (hid_t type_id, unsigned membno)
| Returns the datatype of the specified member.
herr_t | H5Tinsert (hid_t parent_id, const char *name, size_t offset, hid_t member_id)
| Adds a new member to a compound datatype.
herr_t | H5Tpack (hid_t type_id)
| Recursively removes padding from within a compound datatype.

## Function Documentation

## ◆ H5Tget_member_class()

H5T_class_t H5Tget_member_class | ( | hid_t | type_id,
|  | unsigned | membno )

Returns datatype class of compound datatype member.

Parameters

  [in] | type_id | Datatype identifier
  [in] | membno | Zero-based index of the field or element

Returns
  Returns the datatype class, a non-negative value, if successful; otherwise returns a negative value.

Given a compound datatype, `dtype_id`, H5Tget_member_class() returns the datatype class of the member specified by `member_no`.

Valid class identifiers, as defined in H5Tpublic.h, are:

typedef enum H5T_class_t {
H5T_NO_CLASS = -1,
H5T_INTEGER = 0,
H5T_FLOAT = 1,
H5T_TIME = 2,
H5T_STRING = 3,
H5T_BITFIELD = 4,
H5T_OPAQUE = 5,
H5T_COMPOUND = 6,
H5T_REFERENCE = 7,
H5T_ENUM = 8,
H5T_VLEN = 9,
H5T_ARRAY = 10,
H5T_COMPLEX = 11,
H5T_NCLASSES
} H5T_class_t;

Since
  1.4.0

## ◆ H5Tget_member_offset()

size_t H5Tget_member_offset | ( | hid_t | type_id,
|  | unsigned | membno )

Retrieves the offset of a field of a compound datatype.

Parameters

  [in] | type_id | Datatype identifier
  [in] | membno | Zero-based index of the field or element

Returns
  Returns the byte offset of the field if successful; otherwise returns 0 (zero).

H5Tget_member_offset() retrieves the byte offset of the beginning of a field within a compound datatype with respect to the beginning of the compound datatype datum.

Note that zero is a valid offset and that this function will fail only if a call to H5Tget_member_class() fails with the same arguments.

Version
  1.6.4 `member_no` parameter type changed to unsigned.

Since
  1.0.0

## ◆ H5Tget_member_type()

hid_t H5Tget_member_type | ( | hid_t | type_id,
|  | unsigned | membno )

Returns the datatype of the specified member.

Parameters

  [in] | type_id | Datatype identifier
  [in] | membno | Zero-based index of the field or element

Returns
  Returns the identifier of a copy of the datatype of the field if successful; otherwise returns a negative value.

H5Tget_member_type() returns the datatype of the specified member. The caller should invoke H5Tclose() to release resources associated with the type.

Version
  1.6.4 `membno` parameter type changed to unsigned.

Since
  1.0.0

## ◆ H5Tinsert()

herr_t H5Tinsert | ( | hid_t | parent_id,
|  | const char * | name,
|  | size_t | offset,
|  | hid_t | member_id )

Adds a new member to a compound datatype.

Parameters

  [in] | parent_id | Datatype identifier
  [in] | name | Name of the field to insert
  [in] | offset | Offset in memory structure of the field to insert
  [in] | member_id | Datatype identifier of the field to insert

Returns
  Returns a non-negative value if successful; otherwise, returns a negative value.

H5Tinsert() adds another member to the compound datatype, specified `type_id`.

The new member has a `name` which must be unique within the compound datatype. The `offset` argument defines the start of the member in an instance of the compound datatype, and `member_id` is the datatype identifier of the new member.

Note
  Members of a compound datatype do not have to be atomic datatypes; a compound datatype can have a member which is a compound datatype.

Since
  1.0.0

## ◆ H5Tpack()

herr_t H5Tpack | ( | hid_t | type_id | ) |

Recursively removes padding from within a compound datatype.

Parameters

  [in] | type_id | Datatype identifier

Returns
  Returns a non-negative value if successful; otherwise, returns a negative value.

H5Tpack() recursively removes padding from within a compound datatype to make it more efficient (space-wise) to store that data.

Since
  1.0.0