Initial packaging for Tizen
[profile/ivi/gobject-introspection.git] / girepository / cmph / debug.h
1 #ifdef DEBUGP
2 #undef DEBUGP
3 #endif
4
5 #ifdef __cplusplus
6 #include <cstdio>
7 #ifdef WIN32
8 #include <cstring>
9 #endif
10 #else
11 #include <stdio.h>
12 #ifdef WIN32
13 #include <string.h>
14 #endif
15 #endif
16
17 #ifndef __GNUC__
18 #ifndef __DEBUG_H__
19 #define __DEBUG_H__
20 #include <stdarg.h>
21 static void debugprintf(const char *format, ...)
22 {
23     va_list ap;
24         char *f = NULL;
25         const char *p="%s:%d ";
26         size_t plen = strlen(p);
27     va_start(ap, format);
28         f = (char *)malloc(plen + strlen(format) + 1);
29         if (!f) return;
30         memcpy(f, p, plen);
31         memcpy(f + plen, format, strlen(format) + 1);
32     vfprintf(stderr, f, ap);
33     va_end(ap);
34         free(f);
35 }
36 static void dummyprintf(const char *format, ...)
37 {}
38 #endif
39 #endif
40
41 #ifdef DEBUG
42 #ifndef __GNUC__
43 #define DEBUGP debugprintf
44 #else
45 #define DEBUGP(args...) do { fprintf(stderr, "%s:%d ", __FILE__, __LINE__); fprintf(stderr, ## args); } while(0)
46 #endif
47 #else
48 #ifndef __GNUC__
49 #define DEBUGP dummyprintf
50 #else
51 #define DEBUGP(args...)
52 #endif
53 #endif