From dd408da3f428c51331f9d07982467885583e080d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 3 Jul 2014 12:20:50 -0700 Subject: [PATCH] resolve naming conflict on windows. --- src/callback.c | 12 ++++++------ src/callback.h | 10 +++++----- src/callback.test.c | 7 ++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/callback.c b/src/callback.c index f37f14ae7..c2d178819 100644 --- a/src/callback.c +++ b/src/callback.c @@ -6,12 +6,12 @@ static struct reg { struct reg * next; - CALLBACK cb; + HCALLBACK cb; char *name; } *registry; -CALLBACK create_callback(void (*cbv)(va_list va)) { - CALLBACK cb; +HCALLBACK create_callback(void(*cbv)(va_list va)) { + HCALLBACK cb; cb.cbv = cbv; return cb; } @@ -26,7 +26,7 @@ void reset_callbacks(void) { registry = 0; } -CALLBACK register_callback(const char *name, void (*cbv)(va_list va)) +HCALLBACK register_callback(const char *name, void(*cbv)(va_list va)) { struct reg * r = (struct reg *)malloc(sizeof(struct reg)); r->next = registry; @@ -36,7 +36,7 @@ CALLBACK register_callback(const char *name, void (*cbv)(va_list va)) return r->cb; } -int find_callback(const char *name, CALLBACK *result) { +int find_callback(const char *name, HCALLBACK *result) { if (result && name) { struct reg *r; for (r=registry;r;r=r->next) { @@ -49,7 +49,7 @@ int find_callback(const char *name, CALLBACK *result) { return -1; } -int call_callback(CALLBACK cb, const char *name, ... ) { +int call_callback(HCALLBACK cb, const char *name, ...) { va_list ap; if (name) { int err = find_callback(name, &cb); diff --git a/src/callback.h b/src/callback.h index b7f592161..f7b0d71ea 100644 --- a/src/callback.h +++ b/src/callback.h @@ -5,12 +5,12 @@ typedef struct { void (*cbv)(va_list va); -} CALLBACK; +} HCALLBACK; -CALLBACK register_callback(const char *name, void (*cbv)(va_list va)); -CALLBACK create_callback(void (*cbv)(va_list va)); -int find_callback(const char *name, CALLBACK *result); -int call_callback(CALLBACK cb, const char *name, ...); +HCALLBACK register_callback(const char *name, void(*cbv)(va_list va)); +HCALLBACK create_callback(void(*cbv)(va_list va)); +int find_callback(const char *name, HCALLBACK *result); +int call_callback(HCALLBACK cb, const char *name, ...); void reset_callbacks(void); #endif diff --git a/src/callback.test.c b/src/callback.test.c index b5fcba34b..fbc68ddea 100644 --- a/src/callback.test.c +++ b/src/callback.test.c @@ -9,7 +9,7 @@ void callback(va_list ap) { } static void test_find_callback(CuTest *tc) { - CALLBACK cb; + HCALLBACK cb; reset_callbacks(); CuAssertIntEquals(tc, -1, find_callback("test", &cb)); cb = register_callback("test", callback); @@ -18,7 +18,7 @@ static void test_find_callback(CuTest *tc) { } static void test_call_by_handle(CuTest *tc) { - CALLBACK cb; + HCALLBACK cb; int x = 0; reset_callbacks(); cb = create_callback(callback); @@ -28,7 +28,8 @@ static void test_call_by_handle(CuTest *tc) { } static void test_call_by_name(CuTest *tc) { - CALLBACK cb, ca; + HCALLBACK cb = { 0 }; + HCALLBACK ca = { 0 }; int x = 0; reset_callbacks(); CuAssertIntEquals(tc, -1, call_callback(cb, "test", 42, &x));