Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / nsgmls / macros.h
1 /* $XConsortium: macros.h /main/1 1996/07/29 17:08:55 cde-hp $ */
2 // Copyright (c) 1994 James Clark
3 // See the file COPYING for copying permission.
4
5 #ifndef macros_INCLUDED
6 #define macros_INCLUDED 1
7
8 #ifndef __GNUG__
9 #define __attribute__(args) /* as nothing */
10 #endif
11
12 #ifdef NDEBUG
13
14 #include <stdlib.h>
15 #define ASSERT(expr) ((void)0)
16 #define CANNOT_HAPPEN() ((void)abort())
17
18 #else /* not NDEBUG */
19
20 #ifdef SP_NAMESPACE
21 namespace SP_NAMESPACE {
22 #endif
23 extern SP_API void assertionFailed(const char *, const char *, int)
24      __attribute__((noreturn));
25 #ifdef SP_NAMESPACE
26 }
27 #endif
28
29 #define ASSERT(expr) \
30   ((void)((expr) || \
31   (::SP_NAMESPACE_SCOPE assertionFailed(# expr, __FILE__, __LINE__), 0)))
32 #define CANNOT_HAPPEN() ASSERT(0)
33
34 #endif /* not NDEBUG */
35
36 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
37
38 #endif /* not macros_INCLUDED */