---
name: "gd_endianness"
section: "3"
platform: "linux"
package: "libgetdata-doc"
version: "0.11.0-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gd_endianness"
---

# gd\_endianness(3)

report the byte sex of fields in a Dirfile

## NAME

gd\_endianness — report the byte sex of fields in a Dirfile

## SYNOPSIS

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

**unsigned long gd\_endianness(DIRFILE \****dirfile***, int** *fragment\_index***);**

## DESCRIPTION

The **gd\_endianness**() function queries a [dirfile(5)](/dirfile/5.md) database specified by *dirfile* and retrieves the byte sex of the fragment indexed by *fragment\_index*. The byte sex of a fragment indicates the endianness of data files associated with **RAW** fields defined in the specified fragment.  The endianness of a fragment containing no **RAW** fields is not meaningful.

The *dirfile* argument must point to a valid DIRFILE object previously created by a call to [**gd\_open**(3)](/gd_open/3.md).

## RETURN VALUE

Upon successful completion, **gd\_endianness**() returns the byte sex of the specified fragment, which will be either **GD\_BIG\_ENDIAN** or **GD\_LITTLE\_ENDIAN**. This will be bitwise-or'd with either **GD\_ARM\_ENDIAN** or  **GD\_NOT\_ARM\_ENDIAN**, indicating whether double-precision floating point data in this fragment are stored in the old ARM middle-endian format.

On error, this function returns zero and stores a negative-valued error code in the **DIRFILE** object which may be retrieved by a subsequent call to [**gd\_error**(3)](/gd_error/3.md). Possible error codes are:\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_BAD\_INDEX** The supplied index was out of range.

A descriptive error string for the error may be obtained by calling [**gd\_error\_string**(3)](/gd_error_string/3.md).

## HISTORY

The **get\_endianness**() function appeared in GetData-0.5.0.

In GetData-0.7.0, this function was renamed to **gd\_endianness**(). This version also added the **GD\_ARM\_ENDIAN** and  **GD\_NOT\_ARM\_ENDIAN** flags.

## SEE ALSO

[**gd\_alter\_endianness**(3)](/gd_alter_endianness/3.md), [**gd\_getdata**(3)](/gd_getdata/3.md), [**gd\_error**(3)](/gd_error/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md), [**gd\_open**(3)](/gd_open/3.md), [dirfile(5)](/dirfile/5.md), [dirfile-format(5)](/dirfile-format/5.md)
