openldap/libraries/liblber/assert.c
Kurt Zeilenga f999e1350d Provide global assert solution. <ac/assert.h> (new) is now included
by portable.h with NDEBUG undefined.  This makes assert() is always
available and automatically disables itself when LDAP_DEBUG is undefined.
I've included a basic assert() for pre-STDC compilers.  It relies on
abort() which may not actually be available.  (well replace abort()
with whatever is appropriate if and when we're faced with a pre-STDC
compiler that doesn't have assert()).
1999-03-20 03:13:24 +00:00

35 lines
831 B
C

/*
* Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
*/
#include "portable.h"
#ifdef LDAP_NEED_ASSERT
#include <ac/stdio.h>
/*
* helper for our private assert() macro
*
* note: if assert() doesn't exist, like abort() or raise() won't either.
* could use kill() but that might be problematic. I'll just ignore this
* issue for now.
*/
void lber_pvt_assert(char* file, int line, char* test)
{
fprintf(stderr,
"Assertion failed: %s, file %s, line %d\n",
test, file, line);
abort();
}
#endif