*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->NetBSD man pages -> _DIAGASSERT (3)              
Title
Content
Arch
Section
 

_DIAGASSERT(3)

Contents


NAME    [Toc]    [Back]

     _DIAGASSERT - expression verification macro

SYNOPSIS    [Toc]    [Back]

     #include <assert.h>

     _DIAGASSERT(expression);

DESCRIPTION    [Toc]    [Back]

     The _DIAGASSERT() macro tests the given expression and if it is false,
     one or more of the following may occur:

           +o   a diagnostic message may be logged to the system logger with
               syslog(3).  This is default behaviour.

           +o   a diagnostic message may be printed to the stderr stream.

           +o   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.

     If expression is true, the _DIAGASSERT() macro does nothing.

     The _DIAGASSERT() macro is not compiled in by default, and will only be
     compiled in with the cc(1) option -D_DIAGNOSTIC.

     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.

ENVIRONMENT    [Toc]    [Back]

     The LIBC_DIAGNOSTIC environment variable can be used to modify the
     default behaviour of logging the assertion to the system logger.

     LIBC_DIAGNOSTIC may be set to one or more of the following characters:

           a    abort(3) once any assertion messages have been logged and/or
                printed.

           A    Opposite of ``a''.

           e    Print the assertion message to the stderr stream.

           E    Opposite of ``e''.

           l    Log the assertion message with syslog(3) to the facility
                user.debug.

           L    Opposite of ``l''.

DIAGNOSTICS    [Toc]    [Back]

     The diagnostic message has the following format:

           "assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n",
                       "expression", __FILE__, __LINE__, __func__

SEE ALSO    [Toc]    [Back]

      
      
     cc(1), abort(3), assert(3)

HISTORY    [Toc]    [Back]

     The _DIAGASSERT macro appeared in NetBSD 1.5.

BSD                             January 4, 2001                            BSD
[ Back ]
 Similar pages
Name OS Title
KASSERT FreeBSD kernel expression verification macro
m4 HP-UX macro processor
m4 Linux GNU macro processor
m4 Tru64 GNU m4 macro processor
m4 IRIX macro processor
tt_ptr_error HP-UX pointer error macro
gasp FreeBSD the GNU Assembler Macro Preprocessor
XmInternAtom HP-UX A macro that returns an atom for a given name
m4 FreeBSD macro language processor
m4 OpenBSD macro language processor
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service