The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros
asserts.hpp File Reference
#include <cstdlib>
#include <iostream>
#include <csignal>
Include dependency graph for asserts.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BREAKPOINT()
 
#define WES_HALT()   abort()
 
#define ERROR_LOG(a)
 
#define ASSERT_LOG(a, b)   if (!(a)) { ERROR_LOG(b); } else (void)0
 
#define FATAL_ERROR   ERROR_LOG("FATAL ERROR")
 
#define UNREACHABLE_CODE   ERROR_LOG("REACHED UNREACHABLE CODE")
 Marker for code that should be unreachable. More...
 
#define ASSERT_OP(a, op, b)   ASSERT_LOG((a) op (b), #a " " #op " " #b " (" << (a) << " " #op " " << (b) << ")")
 
#define ASSERT_EQ(a, b)   ASSERT_OP(a,==,b)
 
#define ASSERT_NE(a, b)   ASSERT_OP(a,!=,b)
 
#define ASSERT_GE(a, b)   ASSERT_OP(a,>=,b)
 
#define ASSERT_LE(a, b)   ASSERT_OP(a,<=,b)
 
#define ASSERT_GT(a, b)   ASSERT_OP(a,>,b)
 
#define ASSERT_LT(a, b)   ASSERT_OP(a,<,b)
 

Macro Definition Documentation

#define ASSERT_EQ (   a,
  b 
)    ASSERT_OP(a,==,b)

Definition at line 66 of file asserts.hpp.

#define ASSERT_GE (   a,
  b 
)    ASSERT_OP(a,>=,b)

Definition at line 68 of file asserts.hpp.

#define ASSERT_GT (   a,
  b 
)    ASSERT_OP(a,>,b)

Definition at line 70 of file asserts.hpp.

#define ASSERT_LE (   a,
  b 
)    ASSERT_OP(a,<=,b)

Definition at line 69 of file asserts.hpp.

#define ASSERT_LOG (   a,
  b 
)    if (!(a)) { ERROR_LOG(b); } else (void)0
#define ASSERT_LT (   a,
  b 
)    ASSERT_OP(a,<,b)

Definition at line 71 of file asserts.hpp.

#define ASSERT_NE (   a,
  b 
)    ASSERT_OP(a,!=,b)

Definition at line 67 of file asserts.hpp.

#define ASSERT_OP (   a,
  op,
  b 
)    ASSERT_LOG((a) op (b), #a " " #op " " #b " (" << (a) << " " #op " " << (b) << ")")

Definition at line 61 of file asserts.hpp.

#define BREAKPOINT ( )

Definition at line 38 of file asserts.hpp.

#define ERROR_LOG (   a)
#define FATAL_ERROR   ERROR_LOG("FATAL ERROR")

Definition at line 51 of file asserts.hpp.

#define UNREACHABLE_CODE   ERROR_LOG("REACHED UNREACHABLE CODE")

Marker for code that should be unreachable.

This can be used to avoid compiler warnings and to detect logic errors in the code.

Definition at line 58 of file asserts.hpp.

#define WES_HALT ( )    abort()

Definition at line 39 of file asserts.hpp.