---
name: "xo_parse_args"
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_parse_args"
---

# xo\_parse\_args(3)

detect, parse, and remove arguments for libxo

## NAME

**xo\_parse\_args**, **xo\_set\_program** – detect, parse, and remove arguments for libxo

## LIBRARY

library “libxo”

## SYNOPSIS

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

*int*\

**xo\_parse\_args**(*int argc*, *char \*\*argv*);

*int*\

**xo\_set\_program**(*const char \*name*);

## DESCRIPTION

The **xo\_parse\_args**() function is used to process command-line arguments, which are described in [xo\_options(7)](/xo_options/7.md). **libxo** specific options are processed and removed from the argument list so the calling application does not need to process them. If successful, a new value for argc is returned. On failure, a message it emitted and -1 is returned.

```
    argc = xo_parse_args(argc, argv);
    if (argc < 0)
        exit(EXIT_FAILURE);
```

Following the call to **xo\_parse\_args**(), the application can process the remaining arguments in a normal manner.

The **xo\_set\_program**() function sets name of the program as reported by functions like **xo\_failure**(), **xo\_warn**(), **xo\_err**(), etc. The program name is initialized by **xo\_parse\_args**(), but subsequent calls to **xo\_set\_program**() can override this value.

Note that the value is not copied, so the memory passed to **xo\_set\_program**() (and **xo\_parse\_args**()) must be maintained by the caller.

## SEE ALSO

[xo\_emit(3)](/xo_emit/3.md), xo\_options(7,) [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*⟩.
