Blender  V2.93
GHOST_Debug.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
25 #pragma once
26 
27 #ifdef _MSC_VER
28 # ifdef DEBUG
29 /* Suppress STL-MSVC debug info warning. */
30 # pragma warning(disable : 4786)
31 # endif
32 #endif
33 
34 #ifdef WITH_GHOST_DEBUG
35 # include <iostream>
36 # include <stdio.h> //for printf()
37 #endif // WITH_GHOST_DEBUG
38 
39 #ifdef WITH_GHOST_DEBUG
40 # define GHOST_PRINT(x) \
41  { \
42  std::cout << x; \
43  } \
44  (void)0
45 # define GHOST_PRINTF(x, ...) \
46  { \
47  printf(x, __VA_ARGS__); \
48  } \
49  (void)0
50 #else // WITH_GHOST_DEBUG
51 # define GHOST_PRINT(x)
52 # define GHOST_PRINTF(x, ...)
53 #endif // WITH_GHOST_DEBUG
54 
55 #ifdef WITH_ASSERT_ABORT
56 # include <stdio.h> //for fprintf()
57 # include <stdlib.h> //for abort()
58 # define GHOST_ASSERT(x, info) \
59  { \
60  if (!(x)) { \
61  fprintf(stderr, "GHOST_ASSERT failed: "); \
62  fprintf(stderr, info); \
63  fprintf(stderr, "\n"); \
64  abort(); \
65  } \
66  } \
67  (void)0
68 #elif defined(WITH_GHOST_DEBUG)
69 # define GHOST_ASSERT(x, info) \
70  { \
71  if (!(x)) { \
72  GHOST_PRINT("GHOST_ASSERT failed: "); \
73  GHOST_PRINT(info); \
74  GHOST_PRINT("\n"); \
75  } \
76  } \
77  (void)0
78 #else // WITH_GHOST_DEBUG
79 # define GHOST_ASSERT(x, info) ((void)0)
80 #endif // WITH_GHOST_DEBUG