---
name: "xo_err"
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/xo_err"
---

# xo\_err(3)

emit errors and warnings in multiple output styles

## NAME

**xo\_err**, **xo\_errc**, **xo\_errx** **xo\_warn**, **xo\_warnx**, **xo\_warn\_c**, **xo\_warn\_hc** – emit errors and warnings in multiple output styles

## LIBRARY

library “libxo”

## SYNOPSIS

**#include \<libxo/xo.h\>**

*void*\

**xo\_warn**(*const char \*fmt*, *...*);

*void*\

**xo\_warnx**(*const char \*fmt*, *...*);

*void*\

**xo\_warn\_c**(*int code*, *const char \*fmt*, *...*);

*void*\

**xo\_warn\_hc**(*xo\_handle\_t \*xop*, *int code, const char \*fmt*, *...*);

*void*\

**xo\_err**(*int eval*, *const char \*fmt*, *...*);

*void*\

**xo\_errc**(*int eval*, *int code*, *const char \*fmt*, *...*);

*void*\

**xo\_errx**(*int eval*, *const char \*fmt*, *...*);

## DESCRIPTION

Many programs make use of the standard library functions [err(3)](/err/3.md) and [warn(3)](/warn/3.md) to generate errors and warnings for the user. **libxo** wants to pass that information via the current output style, and provides compatible functions to allow this.

The *fmt* argument is one compatible with [printf(3)](/printf/3.md) rather than [xo\_emit(3)](/xo_emit/3.md) to aid in simple conversion.  This means these functions make unstructured data. To generate structured data, use the [xo\_emit\_err(3)](/xo_emit_err/3.md) functions.

These functions display the program name, a colon, a formatted message based on the arguments, and then optionally a colon and an error message associated with either *errno* or the *code* parameter.

```
    EXAMPLE:
        if (open(filename, O_RDONLY) < 0)
            xo_err(1, "cannot open file '%s'", filename);
```

## SEE ALSO

[xo\_emit(3)](/xo_emit/3.md), [xo\_emit\_err(3)](/xo_emit_err/3.md), [libxo(3)](/libxo/3.md)

## HISTORY

The **libxo** library first appeared in FreeBSD 11.0.

## AUTHORS

**libxo** was written by Phil Shafer ⟨*phil@freebsd.org*⟩.
