1
0
mirror of http://mpg123.de/trunk/.git synced 2025-08-06 10:02:38 +03:00

now also warnings and error messages as macro

git-svn-id: svn://scm.orgis.org/mpg123/trunk@337 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
thor
2006-08-05 14:55:26 +00:00
parent 3166029610
commit a501c23941
2 changed files with 48 additions and 13 deletions

View File

@@ -38,18 +38,27 @@ print "#else\n";
printdefs(0); printdefs(0);
print "#endif\n"; print "#endif\n";
for('warning', 'error')
{
print "\n/* $_ macros also here... */\n";
printdefs(1, $_);
}
sub printdefs sub printdefs
{ {
my $forreal = shift; my $forreal = shift;
my $type = shift;
$type = 'debug' unless defined $type;
my $i; my $i;
while(++$i <= $num+1) while(++$i <= $num+1)
{ {
my @args, my $j; my @args, my $j;
while(++$j < $i){ push(@args, chr(ord('a')+$j-1)); } while(++$j < $i){ push(@args, chr(ord('a')+$j-1)); }
unshift(@args, '') if(@args); unshift(@args, '') if(@args);
print ' #define debug'.($i > 1 ? ($i-1) : '').'(s'; print ' #define '.$type.($i > 1 ? ($i-1) : '').'(s';
print join(', ', @args).') '; 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"; } else{ print "{}\n"; }
} }
} }

View File

@@ -26,17 +26,17 @@
#ifdef DEBUG #ifdef DEBUG
#include <stdio.h> #include <stdio.h>
#define debug(s) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__) #define debug(s) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__)
#define debug1(s, a) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a) #define debug1(s, a) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a)
#define debug2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] " s "\n", __LINE__, a, b) #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] " s "\n", __LINE__, a, b, c) #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] " s "\n", __LINE__, a, b, c, d) #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] " s "\n", __LINE__, a, b, c, d, e) #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] " s "\n", __LINE__, a, b, c, d, e, f) #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] " s "\n", __LINE__, a, b, c, d, e, f, g) #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] " s "\n", __LINE__, a, b, c, d, e, f, g, h) #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] " s "\n", __LINE__, a, b, c, d, e, f, g, h, i) #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] " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j) #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 #else
#define debug(s) {} #define debug(s) {}
#define debug1(s, a) {} #define debug1(s, a) {}
@@ -50,3 +50,29 @@
#define debug9(s, a, b, c, d, e, f, g, h, i) {} #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) {} #define debug10(s, a, b, c, d, e, f, g, h, i, j) {}
#endif #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)