Blender  V3.3
GHOST_Debug.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
9 #pragma once
10 
11 #ifdef _MSC_VER
12 # ifdef DEBUG
13 /* Suppress STL-MSVC debug info warning. */
14 # pragma warning(disable : 4786)
15 # endif
16 #endif
17 
18 #if defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))
19 # include <iostream>
20 # include <stdio.h> //for printf()
21 #endif // WITH_GHOST_DEBUG
22 
23 #if defined(WITH_GHOST_DEBUG)
24 # define GHOST_PRINT(x) \
25  { \
26  std::cout << x; \
27  } \
28  (void)0
29 # define GHOST_PRINTF(x, ...) \
30  { \
31  printf(x, __VA_ARGS__); \
32  } \
33  (void)0
34 #else
35 # define GHOST_PRINT(x)
36 # define GHOST_PRINTF(x, ...)
37 #endif /* `!defined(WITH_GHOST_DEBUG)` */
38 
39 #ifdef WITH_ASSERT_ABORT
40 # include <stdio.h> //for fprintf()
41 # include <stdlib.h> //for abort()
42 # define GHOST_ASSERT(x, info) \
43  { \
44  if (!(x)) { \
45  fprintf(stderr, "GHOST_ASSERT failed: "); \
46  fprintf(stderr, info); \
47  fprintf(stderr, "\n"); \
48  abort(); \
49  } \
50  } \
51  (void)0
52 /* Assert in non-release builds too. */
53 #elif defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))
54 # define GHOST_ASSERT(x, info) \
55  { \
56  if (!(x)) { \
57  GHOST_PRINT("GHOST_ASSERT failed: "); \
58  GHOST_PRINT(info); \
59  GHOST_PRINT("\n"); \
60  } \
61  } \
62  (void)0
63 #else /* `defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))` */
64 # define GHOST_ASSERT(x, info) ((void)0)
65 #endif /* `defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))` */