TPIE

11a2c2d
tpie_assert.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2008, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 
23 
24 #ifndef _TPIE_ASSERT_H
25 #define _TPIE_ASSERT_H
26 
27 #include <tpie/config.h>
28 
29 // Get definitions for working with Unix and Windows
30 #include <tpie/portability.h>
31 #include <iostream>
32 #include <tpie/tpie_log.h>
33 #include <cassert>
34 
35 namespace tpie {
36 
43 #define tp_assert_release(condition,message) { \
44  if (!((condition) && 1)) { \
45  TP_LOG_FATAL_ID("Assertion failed:"); \
46  TP_LOG_FATAL_ID(message); \
47  std::cerr << "Assertion (" #condition ") failed " __FILE__ ":" \
48  << __LINE__ << ": " << message << "\n"; \
49  std::terminate(); \
50  assert(condition); \
51  } \
52 }
53 
54 #if !defined(TPIE_NDEBUG) || defined(DOXYGEN)
55 
56 #ifdef _WIN32
57 #pragma warning ( disable : 4127 )
58 #endif
59 
65 #define tp_assert(condition,message) tp_assert_release(condition,message)
66 #else // TPIE_NDEBUG
67 #define tp_assert(condition,message)
68 #endif // TPIE_NDEBUG
69 
70 } // tpie namespace
71 
72 #endif // _TPIE_ASSERT_H
73 
portability.h
tpie_log.h
tpie
Definition: access_type.h:26