Back to index

glibc  2.9
Functions | Variables
assert.c File Reference
#include <assert.h>
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysdep.h>
#include <unistd.h>

Go to the source code of this file.

Functions

void __assert_fail (const char *assertion, const char *file, unsigned int line, const char *function)

Variables

const char * __progname

Function Documentation

void __assert_fail ( const char *  assertion,
const char *  file,
unsigned int  line,
const char *  function 
)

Definition at line 48 of file assert.c.

{
  char *buf;

#ifdef FATAL_PREPARE
  FATAL_PREPARE;
#endif

  if (__asprintf (&buf, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"),
                __progname, __progname[0] ? ": " : "",
                file, line,
                function ? function : "", function ? ": " : "",
                assertion) >= 0)
    {
      /* Print the message.  */
      (void) __fxprintf (NULL, "%s", buf);
      (void) fflush (stderr);

      /* We have to free the buffer since the application might catch the
        SIGABRT.  */
      free (buf);
    }
  else
    {
      /* At least print a minimal message.  */
      static const char errstr[] = "Unexpected error.\n";
      __libc_write (STDERR_FILENO, errstr, sizeof (errstr) - 1);
    }

  abort ();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 24 of file init-misc.c.