BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Assert.h
Go to the documentation of this file.
1
// ************************************************************************************************
2
//
3
// BornAgain: simulate and fit reflection and scattering
4
//
5
//! @file Base/Utils/Assert.h
6
//! @brief Defines the macro ASSERT.
7
//!
8
//! @homepage http://www.bornagainproject.org
9
//! @license GNU General Public License v3 or higher (see COPYING)
10
//! @copyright Forschungszentrum Jülich GmbH 2018
11
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12
//
13
// ************************************************************************************************
14
15
#ifdef SWIG
16
#error no need to expose this header to Swig
17
#endif
18
19
#ifndef USER_API
20
#ifndef BORNAGAIN_BASE_UTILS_ASSERT_H
21
#define BORNAGAIN_BASE_UTILS_ASSERT_H
22
23
// ASSERT must be declared as a macro, not a function, in order for the error
24
// message to correctly report the source line where the assertion failed.
25
26
// For an alternative implementation that calls qFatal, see Base/Utils/Assert.h < 29oct20.
27
28
#include <sstream>
29
#include <stdexcept>
30
31
#define ASSERT(condition) \
32
if (!(condition)) { \
33
std::stringstream msg; \
34
msg << "Assertion "
<< (#condition) << " failed in " << __FILE__ << ", line " << __LINE__; \
35
throw std::runtime_error(msg.str()); \
36
}
37
38
#endif
// BORNAGAIN_BASE_UTILS_ASSERT_H
39
#endif
// USER_API
Base
Utils
Assert.h
Generated by
1.9.1