Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

at_assert.h

Go to the documentation of this file.
00001 //
00002 // The Austria library is copyright (c) Gianni Mariani 2004.
00003 // 
00004 // Grant Of License.  Grants to LICENSEE the non-exclusive right to use the Austria
00005 // library subject to the terms of the LGPL.
00006 // 
00007 // A copy of the license is available in this directory or one may be found at this URL:
00008 //      http://www.gnu.org/copyleft/lesser.txt
00009 // 
00015 #ifndef x_at_assert_h_x
00016 #define x_at_assert_h_x 1
00017 
00018 #include "at_os.h"
00019 
00020 // Austria namespace
00021 namespace at
00022 {
00023 
00024 // ======== AT_Assert ==================================================
00030 #ifdef AT_USE_OS_ASSERT
00031 
00032 #include <cassert>
00033 #include <cstdlib>
00034 
00035 #define AT_Assert(A)  assert(A)
00036 #define AT_Abort()  abort()
00037 #else
00038 
00039 // ======== AT_Assert =================================================
00046 #if AT_DebugBuild
00047 
00048 #define AT_Assert(A)                                                    \
00049     do {                                                                \
00050         if ( ! (A) ) {                                                  \
00051             if ( ::at::OSTraitsBase::GetRunningTestCase() ) {           \
00052                 ::at::OSTraitsBase::TestCaseAssert( __FILE__, __LINE__ );\
00053             }                                                           \
00054             /* access violation - prefer this to abort */               \
00055             * ::at::OSTraitsBase::GetAccVioAddr() = 0;                  \
00056         }                                                               \
00057     } while ( false )                                                   \
00058 // end macro AT_Assert
00059                 
00060 #else
00061 #define AT_Assert(A)    do {} while (false)
00062 #endif
00063 
00064 #define AT_Abort()                                                      \
00065     do {                                                                \
00066         if ( ::at::OSTraitsBase::GetRunningTestCase() ) {               \
00067             ::at::OSTraitsBase::TestCaseAbort( __FILE__, __LINE__ );    \
00068         }                                                               \
00069         * ::at::OSTraitsBase::GetAccVioAddr() = 0;                      \
00070     } while ( true )                                                    \
00071 // end macro AT_Abort
00072 
00073 #endif
00074 
00075 
00076 #define x_AT_CAT_A_x(i_a, i_b) i_a ## i_b
00077 #define x_AT_CAT_x(i_a, i_b) x_AT_CAT_A_x(i_a, i_b)
00078 #define AT_SuffixLneNumber( i_a ) x_AT_CAT_x( i_a, __LINE__ )
00079 
00080 
00081 // ======== AT_StaticAssert ===========================================
00091 #define AT_StaticAssert( i_condional, i_name )                          \
00092     struct AT_SuffixLneNumber( x_ ## i_name )                           \
00093     { char AT_StaticAssert_____ ## i_name ## _____AT_StaticAssert[ (i_condional) ? 1 : -1 ]; char m_v; }
00094 
00095 }; // namespace
00096 
00097 #endif // x_at_assert_h_x
00098 

Generated for Austria by doxygen and MakeXS at Sun Oct 24 17:35:34 PDT 2004