home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ldapsdk.zip / include / ac / assert.h < prev    next >
C/C++ Source or Header  |  2001-05-30  |  1KB  |  55 lines

  1. /* Generic assert.h */
  2. /* $OpenLDAP: pkg/ldap/include/ac/assert.h,v 1.5.2.4 2001/05/30 05:10:45 kurt Exp $ */
  3. /*
  4.  * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted only as authorized by the OpenLDAP
  9.  * Public License.  A copy of this license is available at
  10.  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
  11.  * top-level directory of the distribution.
  12.  */
  13.  
  14. #ifndef _AC_ASSERT_H
  15. #define _AC_ASSERT_H
  16.  
  17. #undef assert
  18.  
  19. #ifdef LDAP_DEBUG
  20.  
  21. #if defined( HAVE_ASSERT_H ) || defined( STDC_HEADERS )
  22.  
  23. #undef NDEBUG
  24. #include <assert.h>
  25.  
  26. #else /* !(HAVE_ASSERT_H || STDC_HEADERS) */
  27.  
  28. #define LDAP_NEED_ASSERT 1
  29.  
  30. /*
  31.  * no assert()... must be a very old compiler.
  32.  * create a replacement and hope it works
  33.  */
  34.  
  35. LIBLBER_F (void) ber_pvt_assert LDAP_P(( const char *file, int line,
  36.                      const char *test ));
  37.  
  38. /* Can't use LDAP_STRING(test), that'd expand to "test" */
  39. #if defined(__STDC__) || defined(__cplusplus)
  40. #define assert(test) \
  41.     ((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, #test ) )
  42. #else
  43. #define assert(test) \
  44.     ((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, "test" ) )
  45. #endif
  46.  
  47. #endif /* (HAVE_ASSERT_H || STDC_HEADERS) */
  48.  
  49. #else /* !LDAP_DEBUG */
  50. /* no asserts */
  51. #define assert(test) ((void)0)
  52. #endif /* LDAP_DEBUG */
  53.  
  54. #endif /* _AC_ASSERT_H */
  55.