assert.h 1.4 KB

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