Back to index

openldap  2.4.31
assert.h
Go to the documentation of this file.
00001 /* Generic assert.h */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #ifndef _AC_ASSERT_H
00018 #define _AC_ASSERT_H
00019 
00020 #undef assert
00021 
00022 #ifdef LDAP_DEBUG
00023 
00024 #if defined( HAVE_ASSERT_H ) || defined( STDC_HEADERS )
00025 
00026 #undef NDEBUG
00027 #include <assert.h>
00028 
00029 #else /* !(HAVE_ASSERT_H || STDC_HEADERS) */
00030 
00031 #define LDAP_NEED_ASSERT 1
00032 
00033 /*
00034  * no assert()... must be a very old compiler.
00035  * create a replacement and hope it works
00036  */
00037 
00038 LBER_F (void) ber_pvt_assert LDAP_P(( const char *file, int line,
00039        const char *test ));
00040 
00041 /* Can't use LDAP_STRING(test), that'd expand to "test" */
00042 #if defined(__STDC__) || defined(__cplusplus)
00043 #define assert(test) \
00044        ((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, #test ) )
00045 #else
00046 #define assert(test) \
00047        ((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, "test" ) )
00048 #endif
00049 
00050 #endif /* (HAVE_ASSERT_H || STDC_HEADERS) */
00051 
00052 #else /* !LDAP_DEBUG */
00053 /* no asserts */
00054 #define assert(test) ((void)0)
00055 #endif /* LDAP_DEBUG */
00056 
00057 #endif /* _AC_ASSERT_H */