OpenMS
openms/include/OpenMS/CONCEPT/Macros.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg$
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 
12 #include <OpenMS/config.h>
14 
15 #include <string>
16 #include <cstring>
17 
24 #define STRINGIFY(a) #a
25 
26 #ifdef _OPENMP
27 
28 // Pragma string literals are compiler-specific:
29 // gcc and clang use _Pragma while MSVS uses __pragma
30 // the MSVS pragma does not need a string token somehow.
31 #ifdef OPENMS_COMPILER_MSVC
32 #define OPENMS_THREAD_CRITICAL(name) \
33  __pragma(omp critical (name))
34 #else
35 #define OPENMS_THREAD_CRITICAL(name) \
36  _Pragma( STRINGIFY( omp critical (name) ) )
37 #endif
38 
39 #else
40 
41 #define OPENMS_THREAD_CRITICAL(name)
42 
43 #endif
44  // end of helpers
46 
47 
63 #ifdef OPENMS_ASSERTIONS
64 
70 #define OPENMS_PRECONDITION(condition, message) \
71  if (!(condition)) \
72  { \
73  throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, # condition " " # message); \
74  } \
75 
81 #define OPENMS_POSTCONDITION(condition, message) \
82  if (!(condition)) \
83  { \
84  throw Exception::Postcondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, # condition " " # message); \
85  } \
86 
87 #else
88 
94 #define OPENMS_PRECONDITION(condition, message)
95 
101 #define OPENMS_POSTCONDITION(condition, message)
102 
103 #endif
104  // end of Conditions
106