table of contents
        
      
      
    | ERR(3) | Library Functions Manual | ERR(3) | 
NOMBRE¶
err, verr,
    errx, verrx,
    warn, vwarn,
    warnx, vwarnx, —
    mensajes de error con formato
SINOPSIS¶
#include <err.h>
    void
    err(int
    eval, const char *fmt,
    ...) void
    errx(int eval,
    const char *fmt, ...)
    void
    warn(const char *fmt,
    ...) void
    warnx(const char *fmt,
    ...) #include
    <stdarg.h> void
    verr(int eval,
    const char *fmt, va_list args)
    void verrx(int
    eval, const char *fmt, va_list
    args) void
    vwarn(const char *fmt,
    va_list args) void
    vwarnx(const
    char *fmt, va_list args)
DESCRIPCIÓN¶
La familia de funciones err() y
    warn() muestran un mensaje de error con formato en
    la salida estándar de error. En todos los casos, se imprime el
    último componente del nombre del programa, un carácter punto y
    un espacio. Si el argumento fmt es distinto de NULL,
    se imprime un mensaje de error con formato al estilo de
    printf(3)
Las funciones
    err(),
    verr(),
    warn(), y
    vwarn()
    añaden un mensaje de error obtenido con strerror(3)
    basado en un código o en la variable global
    errno, precedido por otro punto y un espacio a menos
    que el argumento fmt sea
  NULL.
Las funciones
    err(),
    verr(),
    warn(), y
    vwarn()
    usan la variable global errno para buscar el mensaje
    de error.
Las funciones
    errx() y
    warnx()
    no añaden ningún mensaje de error.
Las funciones
    err(),
    verr(),
    errx(), y
    verrx()
    no regresan, sino que terminan la ejecución con el valor del
    argumento eval.
EJEMPLOS¶
Muestra la cadena de información del error actual y termina:
if ((p = malloc(size)) == NULL) err(1, NULL); if ((fd = open(file_name, O_RDONLY, 0)) == -1) err(1, "%s", file_name);
Muestra un mensaje de error y termina:
if (tm.tm_hour < START_TIME) errx(1, "too early, wait until %s", start_time_string);
Aviso de un error:
if (
	warnx("%s: %s: trying the block device",
	    raw_device, strerror(errno));
if ((fd = open(block_device, O_RDONLY, 0)) == -1)
	err(1, "%s", block_device);
VÉASE TAMBIÉN¶
HISTORIA¶
Las funciones
    err()
    y
    warn()
    aparecieron por primera vez en 4.4BSD.
| March 6, 1999 | Linux 5.14.0-427.18.1.el9_4.x86_64 |