1
/* vim:expandtab:ts=2 sw=2:
3
/* Grafx2 - The Ultimate 256-color bitmap paint program
5
Copyright 2008 Adrien Destugues
7
Grafx2 is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; version 2
12
Grafx2 is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
21
//////////////////////////////////////////////////////////////////////////////
23
/// Functions and macros for tracing and error reporting.
24
//////////////////////////////////////////////////////////////////////////////
27
#define __func__ "stupid compiler !"
30
/// Prints the source filename, line number, function name, a string and an integer.
31
#define DEBUG(y,z) printf("%s %d %s | %s : %d###\n",__FILE__,__LINE__,__func__,y,(unsigned int)z)
33
/// Same as ::DEBUG but in hexadecimal
34
#define DEBUGX(y,z) printf("%s %d %s | %s : %X###\n",__FILE__,__LINE__,__func__,y,(unsigned int)z)
36
/// Helper function used by the macro ::Error
37
void Error_function(int error_code, const char *filename, int line_number, const char *function_name);
40
/// Report a run-time error: It will print to standard output some information
41
/// about the calling function, and then:
42
/// - If the error code is 0, just do a red screen flash and resume.
43
/// - If the error code is non-zero, abort the program.
44
#define Error(n) Error_function(n, __FILE__,__LINE__,__func__)
46
/// Helper function used by the macro ::Warning
47
void Warning_function(const char *message, const char *filename, int line_number, const char *function_name);
50
/// Report a run-time abnormal condition : It will print to standard output
51
/// some information about the calling function, and then resume silently.
52
/// This is most useful in debugger so you can put a breakpoint on
53
/// ::Warning_function and examine the stack trace.
54
#define Warning(msg) Warning_function(msg, __FILE__,__LINE__,__func__)