NEURON
nrnassrt.h
Go to the documentation of this file.
1 #ifndef nrnassrt_h
2 #define nrnassrt_h
3 
4 /* nrn_assert is not deactivated by -DNDEBUG. Use when the assert expression
5 has side effects which need to be executed regardles of NDEBUG.
6 */
7 
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 #if defined(hocassrt_h) /* hoc_execerror form */
13 
14 #if defined(__cplusplus)
15 extern "C" {
16 #endif
17 
18 extern void hoc_execerror(const char*, const char*);
19 
20 #if defined(__cplusplus)
21 }
22 #endif
23 
24 #if defined(__STDC__)
25 #define nrn_assert(ex) \
26  { \
27  if (!(ex)) { \
28  fprintf(stderr, "Assertion failed: file %s, line %d\n", __FILE__, __LINE__); \
29  hoc_execerror(#ex, (char*) 0); \
30  } \
31  }
32 #else
33 #define nrn_assert(ex) \
34  { \
35  if (!(ex)) { \
36  fprintf(stderr, "Assertion failed: file %s, line %d\n", __FILE__, __LINE__); \
37  hoc_execerror("ex", (char*) 0); \
38  } \
39  }
40 #endif
41 
42 #else /* abort form */
43 
44 #if defined(__STDC__)
45 #define nrn_assert(ex) \
46  { \
47  if (!(ex)) { \
48  fprintf(stderr, "Assertion failed: file %s, line %d\n", __FILE__, __LINE__); \
49  abort(); \
50  } \
51  }
52 #else
53 #define nrn_assert(ex) \
54  { \
55  if (!(ex)) { \
56  fprintf(stderr, "Assertion failed: file %s, line %d\n", __FILE__, __LINE__); \
57  abort(); \
58  } \
59  }
60 #endif
61 
62 #endif
63 
64 
65 #endif
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:754