---
name: "xdf_add_channel"
section: "3"
platform: "linux"
package: "libxdffileio-dev"
version: "0.3-4+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/xdf_add_channel"
---

# xdf\_add\_channel(3)

Appends a channel to a XDF file

## NAME

xdf\_add\_channel - Appends a channel to a XDF file

## SYNOPSIS

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

**struct xdfch\* xdf\_add\_channel(struct xdf\*** *xdf***, const char\*** *label***);**\

## DESCRIPTION

**xdf\_add\_channel**() appends a channel to the file referenced by the handle *xdf*. The new channel is initialized with the *label* argument (if not **NULL**) and with the default channel values set in the XDF file, i.e. those set using channel configuration fields in [**xdf\_set\_conf**(3)](/xdf_set_conf/3.md) (See the related manpage).

If the call to [**xdf\_add\_channel**(3)](/xdf_add_channel/3.md) is successful, the default offset value (the field referenced by **XDF\_CF\_ARROFFSET**) is incremented by the size of the current default stored type (field referenced by **XDF\_CF\_STOTYPE**). As a consequence, if the channel default values have not changed in-between, the next call to **xdf\_add\_channel**() will create a channel whose location is the array will be next to the previous one.

This type of initialization allows the user to add channels without having to specifically pack them: this is achieved by default.

## RETURN VALUE

**xdf\_add\_channel**() returns the handle to newly created channel descriptor in case of success. Otherwise NULL is returned  and *errno* is set appropriately.

## ERRORS

- **EINVAL**

  *xdf* is NULL.

- **ENOMEM**

  The system is unable to allocate resources.

- **EPERM**

  the file referenced by *xdf* has been opened with the mode **XDF\_READ**

## SEE ALSO

[**xdf\_copy\_chconf**(3)](/xdf_copy_chconf/3.md), [**xdf\_set\_conf**(3)](/xdf_set_conf/3.md), [**xdf\_set\_chconf**(3)](/xdf_set_chconf/3.md)
