TPIE

2362a60
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 
37 #if !defined(TPIE_NDEBUG) || defined(DOXYGEN)
38 
39 #ifdef _WIN32
40 #pragma warning ( disable : 4127 )
41 #endif
42 
48 #define tp_assert(condition,message) { \
49  if (!((condition) && 1)) { \
50  TP_LOG_FATAL_ID("Assertion failed:"); \
51  TP_LOG_FATAL_ID(message); \
52  std::cerr << "Assertion (" #condition ") failed " __FILE__ ":" \
53  << __LINE__ << ": " << message << "\n"; \
54  std::terminate(); \
55  assert(condition); \
56  } \
57 }
58 
59 #else // TPIE_NDEBUG
60 #define tp_assert(condition,message)
61 #endif // TPIE_NDEBUG
62 
63 } // tpie namespace
64 
65 #endif // _TPIE_ASSERT_H
66 
This file contains a few deprecated definitions for legacy code.
Logging functionality and log_level codes for different priorities of log messages.