FEDRA emulsion software from the OPERA Collaboration
sassert.hh
Go to the documentation of this file.
1#ifndef __SASSERT_HH
2#define __SASSERT_HH
3// ********************************************************************
4//
5// source:
6//
7// type: source code
8//
9// created: 04. Apr 2001
10//
11// author: Thorsten Glebe
12// HERA-B Collaboration
13// Max-Planck-Institut fuer Kernphysik
14// Saupfercheckweg 1
15// 69117 Heidelberg
16// Germany
17// E-mail: T.Glebe@mpi-hd.mpg.de
18//
19// Description: An assert macro which is invoced only once (in contrast
20// to standard assert(), which is repeatedly called).
21// Sassert is more performant in case it is placed in a routine
22// which is called more than once. Otherwise assert() is more
23// performant.
24//
25// changes:
26// 04 Apr 2001 (TG) creation
27//
28// ********************************************************************
29
35//==============================================================================
36// errfunc
37//==============================================================================
38static bool errfunc(const char* expr, const char* function,
39 const unsigned int line) {
40 cerr << "Error in " << __FILE__ << ", function " << function
41 << ", Line " << line << ": assertion " << expr << " failed!" << endl;
42 exit(-1);
43 return false;
44}
45
55//==============================================================================
56// Sassert
57//==============================================================================
58#define Sassert(expr) static const bool sassertrc = (expr) ? true : errfunc(__STRING(expr),__FUNCTION__,__LINE__)
59#endif