diff options
author | Colin Walters <walters@verbum.org> | 2010-11-11 15:01:07 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-12-03 16:03:31 -0500 |
commit | 3a94a5e36287072486831eb68bfe43a0e1c8ea78 (patch) | |
tree | 59eb83ba02a9acfd7032c2199d6e523e89efe418 /girepository/cmph/debug.h | |
parent | f6e5defff5a8d8ba83e0b414496d28b5e2361f39 (diff) | |
download | gobject-introspection-3a94a5e36287072486831eb68bfe43a0e1c8ea78.tar.gz |
Import CMPH 1.0
This will be used for typelib indexing. See README-CMPH-IMPORT.txt
for more information.
Diffstat (limited to 'girepository/cmph/debug.h')
-rw-r--r-- | girepository/cmph/debug.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/girepository/cmph/debug.h b/girepository/cmph/debug.h new file mode 100644 index 00000000..0f7ddb13 --- /dev/null +++ b/girepository/cmph/debug.h @@ -0,0 +1,53 @@ +#ifdef DEBUGP +#undef DEBUGP +#endif + +#ifdef __cplusplus +#include <cstdio> +#ifdef WIN32 +#include <cstring> +#endif +#else +#include <stdio.h> +#ifdef WIN32 +#include <string.h> +#endif +#endif + +#ifndef __GNUC__ +#ifndef __DEBUG_H__ +#define __DEBUG_H__ +#include <stdarg.h> +static void debugprintf(const char *format, ...) +{ + va_list ap; + char *f = NULL; + const char *p="%s:%d "; + size_t plen = strlen(p); + va_start(ap, format); + f = (char *)malloc(plen + strlen(format) + 1); + if (!f) return; + memcpy(f, p, plen); + memcpy(f + plen, format, strlen(format) + 1); + vfprintf(stderr, f, ap); + va_end(ap); + free(f); +} +static void dummyprintf(const char *format, ...) +{} +#endif +#endif + +#ifdef DEBUG +#ifndef __GNUC__ +#define DEBUGP debugprintf +#else +#define DEBUGP(args...) do { fprintf(stderr, "%s:%d ", __FILE__, __LINE__); fprintf(stderr, ## args); } while(0) +#endif +#else +#ifndef __GNUC__ +#define DEBUGP dummyprintf +#else +#define DEBUGP(args...) +#endif +#endif |