OpenMS
Loading...
Searching...
No Matches
openms/include/OpenMS/CONCEPT/Macros.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
21#define STRINGIFY(a) #a
22
23#ifdef _OPENMP
24
25// Pragma string literals are compiler-specific:
26// gcc and clang use _Pragma while MSVS uses __pragma
27// the MSVS pragma does not need a string token somehow.
28#ifdef OPENMS_COMPILER_MSVC
29#define OPENMS_THREAD_CRITICAL(name) \
30 __pragma(omp critical (name))
31#else
32#define OPENMS_THREAD_CRITICAL(name) \
33 _Pragma( STRINGIFY( omp critical (name) ) )
34#endif
35
36#else
37
38#define OPENMS_THREAD_CRITICAL(name)
39
40#endif
41
// end of helpers
43
44
60#ifdef OPENMS_ASSERTIONS
61
67#define OPENMS_PRECONDITION(condition, message) \
68 if (!(condition)) \
69 { \
70 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, # condition " " # message); \
71 } \
72
78#define OPENMS_POSTCONDITION(condition, message) \
79 if (!(condition)) \
80 { \
81 throw Exception::Postcondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, # condition " " # message); \
82 } \
83
84#else
85
91#define OPENMS_PRECONDITION(condition, message)
92
98#define OPENMS_POSTCONDITION(condition, message)
99
100#endif
101
// end of Conditions
103