Chombo + EB  3.0
CH_assert.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 
12 #ifndef _CH_ASSERT_H_
13 #define _CH_ASSERT_H_
14 
15 #ifdef CH_LANG_CC
16 # include "MayDay.H"
17 #endif
18 
19 #include "BaseNamespaceHeader.H"
20 
21 
22 #ifdef CH_LANG_CC
23 /**
24 @ingroup macros
25 compile-time cpp macro that replaces 'assert()' and aborts
26 correctly when running in parallel. */
27 # ifndef NDEBUG
28 # define CH_assert_str(s) # s
29 # define CH_assert_xstr(s) CH_assert_str(s)
30 # define CH_assert(cond) if (!(cond)) \
31  { \
32  CH_XD::MayDay::Abort( __FILE__ ":" CH_assert_xstr(__LINE__) ": Assertion `" #cond "' failed."); \
33  }
34 # else
35 # define CH_assert(cond) (void)0
36 #endif
37 
38 /** Compile-time assertion */
39 /** (renamed this temp variable as static_assert will become a keyword -- and likely have same functionality) */
40 template<bool> struct diy_static_assert;
41 template<> struct diy_static_assert<true>
42 {
43 };
44 #define STATIC_ASSERT( a ) diy_static_assert<a>()
45 
46 
47 #endif //CH_LANG_CC
48 
49 #ifdef CH_LANG_FORT
50 #ifndef NDEBUG
51 # define CH_assert(cond) if (.NOT. cond) call MAYDAYERROR()
52 #else
53 # define CH_assert(cond)
54 #endif
55 #endif //CH_LANG_FORT
56 
57 
58 #include "BaseNamespaceFooter.H"
59 
60 #endif // include guard
61