Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

err / errx / warn / warnx (verr, verrx, vwarn, vwarnx) - glibc

Split from the chapter glibc: stdio and Formatted I/O into the per-function layout; see the method page and the glibc ledger for coverage status.

FieldValue
IDGLIBC-err (group)
Headererr.h
ProvenanceBSD
Statusdocumented

Signature – void err(int status, const char *format, ...); void errx(int status, const char *format, ...); void warn(const char *format, ...); void warnx(const char *format, ...); plus va_list forms verr, verrx, vwarn, vwarnx.

Semantics – BSD shorthand built on the same output discipline: prefix program_invocation_short_name, ": ", the formatted message, and for the non-x variants ": " plus strerror(errno) – err then exits with status (even 0), warn returns (manual, Error Messages). Equivalences from the manual: warn is roughly error(0, errno, ...) and err roughly error(status, errno, ...) with the error globals untouched; warnx/errx omit the errno text (errx(status, 0, ...) shape). Implicit errno use means the call must come before anything clobbers it. The manual advises preferring error/error_at_line; the BSD set exists for portability with 4.4BSD-derived code (err(3)).