ROSE 0.11.145.147
ROSE_ASSERT.h
1#ifndef ROSE_ASSERT_H
2#define ROSE_ASSERT_H
3
4#include <assert.h>
5#include <stdlib.h>
6
8// ROSE_ASSERT
9//
10// Purpose: Used by ROSE developers to check for their own logic errors when ROSE is configured for debugging. When ROSE is
11// configured for production, this macro does nothing (not even evaulate its argument).
12//
13// Do not use ROSE_ASSERT to simply terminate a process -- ROSE_ASSERT is meant to check for logic errors instead. You could
14// use abort, ROSE_ABORT, exit, kill, throw, or other machanisms to unconditionally terminate a process.
15//
16// Caveats:
17// (1) ROSE_ASSERT is a macro. No overloading, no passing around a pointer, no setting breakpoints, no encapsulation, etc.
18//
19// (2) ROSE_ASSERT takes one Boolean argument that should have no side effects.
20//
21// (3) ROSE_ASSERT will do nothing (not even evaluate its argument) when NDEBUG is defined.
22//
23// These semantics were reached by consensus at ROSE meeting 2021-03-23. If you make behavioral changes here, please discuss
24// them first.
25//
26// We recommend that you use the ASSERT_* macros instead, which hook into ROSE's user configurable diagnostics framework. You
27// can find documentation here:
28// + ASSERT_* macros: http://rosecompiler.org/ROSE_HTML_Reference/namespaceSawyer_1_1Assert.html
29// + Rose::Diagnostics: http://rosecompiler.org/ROSE_HTML_Reference/namespacerose_1_1Diagnostics.html
31
32#ifndef ROSE_ASSERT
33 #if _MSC_VER
34 #define ROSE_ASSERT assert
35 #elif defined(__APPLE__) && defined(__MACH__)
36 // Pei-Hung (06/16/2015) Sawyer is turned off for Mac OSX
37 #define ROSE_ASSERT assert
38 #elif defined(__sun)
39 // PP (05/16/19)
40 #define ROSE_ASSERT assert
41 #elif defined(ROSE_ASSERTION_BEHAVIOR)
42 #ifdef __GNUC__
43 // Pei-Hung (6/16/2015): Using Sawyer ASSERT will consume more than 4GB memory when building ROSE with 32-bit GCC
44 // in version 4.2.4 If building ROSE with GCC older than version 4.4, turn off support for Sawyer assert.
45 #include <features.h>
46 #if __GNUC_PREREQ(4,4)
47 #define ROSE_ASSERT ASSERT_require
48 #else
49 #define ROSE_ASSERT assert
50 #endif
51 #else
52 #define ROSE_ASSERT ASSERT_require
53 #endif
54 #else
55 #define ROSE_ASSERT assert
56 #endif
57#endif
58
59#endif
60