_DIAGASSERT(3)
πΈ NAME: _DIAGASSERT(3) β expression verification macro (Library Functions Manual) πΈ
okay so bestie, welcome to the _DIAGASSERT(3) page π. It's giving library functions manual energy, and the whole thing is about an expression verification macro. No cap.
β¨ SYNOPSIS β¨
#include <assert.h>
_DIAGASSERT(expression);
π DESCRIPTION π
The _DIAGASSERT() macro tests the given expression, and if it's false, one or more of these things may happen:
- a diagnostic message may be logged to the system logger with
syslog(3). This is default behaviour. - a diagnostic message may be printed to the
stderrstream. - the calling process will be terminated by calling
abort(3).
This behaviour may be changed by setting the LIBC_DIAGASSERT environment variable (see below) π.
The diagnostic message consists of the text of the expression, the name of the source file, the line number and the enclosing function. It's literally receipts: expression, file, line, function.
If expression is true, the _DIAGASSERT() macro does nothing. chill, no drama.
The _DIAGASSERT() macro is not compiled in by default, and will only be compiled in with the cc(1) option -D_DIAGNOSTIC. periodt.
This macro is used in the various system libraries such as the Standard C Library (libc, -lc) to ensure that various library calls are invoked with valid arguments. iconic valid-arguments energy.
π¦ ENVIRONMENT π¦
The LIBC_DIAGASSERT environment variable can be used to modify the default behaviour of logging the assertion to the system logger.
LIBC_DIAGASSERT may be set to one or more of the following characters:
aβ callsabort(3)once any assertion messages have been logged and/or printed.Aβ opposite ofa.eβ prints the assertion message to thestderrstream.Eβ opposite ofe.lβ logs the assertion message withsyslog(3)to the facilityuser.debug.Lβ opposite ofl.
π₯ DIAGNOSTICS π₯
The diagnostic message has the following format:
"assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n",
"expression", __FILE__, __LINE__, __func__
π SEE ALSO π
π HISTORY π
The _DIAGASSERT macro appeared in NetBSD 1.5.
xoxo, Debian π β this page is dated January 22, 2007 π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2001 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms