diff --git a/scripts/debugdef.pl b/scripts/debugdef.pl index 30fc6a26..199c212d 100755 --- a/scripts/debugdef.pl +++ b/scripts/debugdef.pl @@ -38,18 +38,27 @@ print "#else\n"; printdefs(0); print "#endif\n"; +for('warning', 'error') +{ + print "\n/* $_ macros also here... */\n"; + printdefs(1, $_); +} + sub printdefs { my $forreal = shift; + my $type = shift; + $type = 'debug' unless defined $type; my $i; while(++$i <= $num+1) { my @args, my $j; while(++$j < $i){ push(@args, chr(ord('a')+$j-1)); } unshift(@args, '') if(@args); - print ' #define debug'.($i > 1 ? ($i-1) : '').'(s'; + print ' #define '.$type.($i > 1 ? ($i-1) : '').'(s'; print join(', ', @args).') '; - if($forreal){ print 'fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__'.join(', ', @args).")\n"; } + if($forreal){ print 'fprintf(stderr, "[" __FILE__ ":%i] '.$type.': " s "\n", __LINE__'.join(', ', @args).")\n"; } else{ print "{}\n"; } } } + diff --git a/src/debug.h b/src/debug.h index 96ea6f3f..9b8ab116 100644 --- a/src/debug.h +++ b/src/debug.h @@ -26,17 +26,17 @@ #ifdef DEBUG #include - #define debug(s) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__) - #define debug1(s, a) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a) - #define debug2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b) - #define debug3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c) - #define debug4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c, d) - #define debug5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c, d, e) - #define debug6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c, d, e, f) - #define debug7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c, d, e, f, g) - #define debug8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c, d, e, f, g, h) - #define debug9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c, d, e, f, g, h, i) - #define debug10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j) + #define debug(s) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__) + #define debug1(s, a) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a) + #define debug2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b) + #define debug3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c) + #define debug4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d) + #define debug5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e) + #define debug6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f) + #define debug7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g) + #define debug8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h) + #define debug9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i) + #define debug10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j) #else #define debug(s) {} #define debug1(s, a) {} @@ -50,3 +50,29 @@ #define debug9(s, a, b, c, d, e, f, g, h, i) {} #define debug10(s, a, b, c, d, e, f, g, h, i, j) {} #endif + +/* warning macros also here... */ + #define warning(s) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__) + #define warning1(s, a) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a) + #define warning2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b) + #define warning3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c) + #define warning4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d) + #define warning5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e) + #define warning6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f) + #define warning7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g) + #define warning8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h) + #define warning9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i) + #define warning10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j) + +/* error macros also here... */ + #define error(s) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__) + #define error1(s, a) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a) + #define error2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b) + #define error3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c) + #define error4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d) + #define error5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e) + #define error6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f) + #define error7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g) + #define error8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h) + #define error9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i) + #define error10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)