EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
epicsAssert.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 
42 #ifndef INC_epicsAssert_H
43 #define INC_epicsAssert_H
44 
45 #include "libComAPI.h"
46 #include "compilerDependencies.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 
53 #ifndef epicsAssertAuthor
54 
55 # define epicsAssertAuthor 0
56 #endif
57 
58 #undef assert
59 
60 #ifdef NDEBUG
61 # define assert(ignore) ((void) 0)
62 #else /* NDEBUG */
63 
65 LIBCOM_API void epicsAssert (const char *pFile, const unsigned line,
66  const char *pExp, const char *pAuthorName);
67 
71 # define assert(exp) ((exp) ? (void)0 : \
72  epicsAssert(__FILE__, __LINE__, #exp, epicsAssertAuthor))
73 
74 #endif /* NDEBUG */
75 
76 
77 /* Compile-time checks */
78 #if __cplusplus>=201103L
79 #define STATIC_ASSERT(expr) static_assert(expr, #expr)
80 #else
81 #define STATIC_JOIN(x, y) STATIC_JOIN2(x, y)
82 #define STATIC_JOIN2(x, y) x ## y
83 
87 #define STATIC_ASSERT(expr) \
88  typedef int STATIC_JOIN(static_assert_failed_at_line_, __LINE__) \
89  [ (expr) ? 1 : -1 ] EPICS_UNUSED
90 #endif
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* INC_epicsAssert_H */
Compiler specific declarations.