Nebula
Loading...
Searching...
No Matches
debug.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
16#include "core/config.h"
17
18void n_printf(const char *, ...) __attribute__((format(printf,1,2)));
19void n_error(const char*, ...) __attribute__((format(printf,1,2)));
20void n_dbgout(const char*, ...) __attribute__((format(printf,1,2)));
21void n_warning(const char*, ...) __attribute__((format(printf,1,2)));
22void n_confirm(const char*, ...) __attribute__((format(printf,1,2)));
23void n_sleep(double);
24void n_barf(const char *, const char *, int);
25void n_barf2(const char*, const char*, const char*, int);
26void n_barf_fmt(const char *, const char *, const char *, int, ...);
27void n_cough(const char*, const char*, int);
28void n_cough2(const char*, const char*, const char*, int);
29void n_cough_fmt(const char*, const char*, const char*, int, ...);
30void n_break();
31
32// backward compatibility
33#define n_message n_confirm
34
35#if __NEBULA_NO_ASSERT__
36#define n_assert(exp) if(!(exp)){}
37#define n_assert2(exp, msg) if(!(exp)){}
38#define n_assert_msg(exp, msg) n_assert2(exp, msg)
39#define n_assert_fmt(exp, msg, ...) if(!(exp)){}
40#define n_verify(exp) (exp)
41#define n_verify2(exp,imsg) (exp)
42#define n_warn(exp) if (!(exp)) {}
43#define n_warn2(exp, msg) if (!(exp)) {}
44#define n_warn_fmt(exp, msg, ...) if (!(exp)) {}
45#if __WIN32__
46#define n_dxtrace(hr, msg)
47#endif
48#define n_static_assert(exp)
49#else
50#define n_assert(exp) { if (!(exp)) n_barf(#exp, __FILE__, __LINE__); }
51#define n_assert2(exp, msg) { if (!(exp)) n_barf2(#exp, msg, __FILE__, __LINE__); }
52#define n_assert_msg(exp, msg) n_assert2(exp, msg)
53#define n_assert_fmt(exp, msg, ...) { if (!(exp)) n_barf_fmt(#exp, msg, __FILE__, __LINE__, __VA_ARGS__); }
54#define n_warn(exp) { if (!(exp)) n_cough(#exp, __FILE__, __LINE__); }
55#define n_warn2(exp, msg) { if (!(exp)) n_cough2(#exp, msg, __FILE__, __LINE__); }
56#define n_warn_fmt(exp, msg, ...) { if (!(exp)) n_cough_fmt(#exp, msg, __FILE__, __LINE__, __VA_ARGS__); }
57#define n_crash(msg) { n_error("*** NEBULA CRASH ***\n%s(%d)\nmessage: %s\n", __FILE__, __LINE__, msg); }
58#define n_static_assert(exp) { int _x[ 2*((exp) != 0)-1 ]; (void)(_x[0]=0);}
59#if __WIN32__
60// dx9 specific: check HRESULT and display DX9 specific message box
61#define n_dxtrace(hr, msg) { if (FAILED(hr)) DXTrace(__FILE__,__LINE__,hr,msg,true); }
62#endif
63#endif
64
65//------------------------------------------------------------------------------
void void void void void n_confirm(const char *,...) __attribute__((format(printf
void n_cough(const char *, const char *, int)
This function is called by n_assert() when the assertion fails.
Definition debug.cc:77
void n_printf(const char *,...) __attribute__((format(printf
void void void n_dbgout(const char *,...) __attribute__((format(printf
void void void void void void n_sleep(double)
Put process to sleep.
Definition debug.cc:239
void n_cough2(const char *, const char *, const char *, int)
This function is called by n_assert2() when the assertion fails.
Definition debug.cc:96
void n_barf(const char *, const char *, int)
This function is called by n_assert() when the assertion fails.
Definition debug.cc:17
void n_cough_fmt(const char *, const char *, const char *, int,...)
Definition debug.cc:114
void void n_error(const char *,...) __attribute__((format(printf
void n_barf2(const char *, const char *, const char *, int)
This function is called by n_assert2() when the assertion fails.
Definition debug.cc:36
void n_break()
Definition debug.cc:248
void void void void n_warning(const char *,...) __attribute__((format(printf
void n_barf_fmt(const char *, const char *, const char *, int,...)
Definition debug.cc:54
Nebula compiler specific defines and configuration.
#define __attribute__(x)
Definition config.h:161