From 40bf8774997dfbd791677a9abd96e3babadef73b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 10 Jan 2014 14:38:54 +0100 Subject: [PATCH] Work around gcc warning about function pointers conversions. Work around harmless (at least under POSIX systems where function pointers are guaranteed to have the same representation as object pointers) but annoying warnings given by gcc when converting between function and object pointers, e.g. Source/DOH/fio.c: In function 'DohEncoding': Source/DOH/fio.c:51: warning: ISO C forbids conversion of function pointer to object pointer type Source/DOH/fio.c: In function 'encode': Source/DOH/fio.c:75: warning: ISO C forbids conversion of object pointer to function pointer type Source/DOH/base.c: In function 'DohCall': Source/DOH/base.c:952: warning: ISO C forbids conversion of object pointer to function pointer type Use an extra level of pointer indirection to avoid them. --- Source/DOH/base.c | 2 +- Source/DOH/fio.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/DOH/base.c b/Source/DOH/base.c index 1f92b6542..e84731cd0 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -949,7 +949,7 @@ DOH *DohCall(DOH *func, DOH *args) { DOH *result; DOH *(*builtin) (DOH *); - builtin = (DOH *(*)(DOH *)) GetVoid(func, "builtin"); + *(void **)(&builtin) = GetVoid(func, "builtin"); if (!builtin) return 0; result = (*builtin) (args); diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c index d2a1bab19..71ce30149 100644 --- a/Source/DOH/fio.c +++ b/Source/DOH/fio.c @@ -48,7 +48,7 @@ static int Writen(DOH *out, void *buffer, int len) { void DohEncoding(const char *name, DOH *(*fn) (DOH *s)) { if (!encodings) encodings = NewHash(); - Setattr(encodings, (void *) name, NewVoid((void *) fn, 0)); + Setattr(encodings, (void *) name, NewVoid(*(void **)&fn, 0)); } /* internal function for processing an encoding */ @@ -72,7 +72,7 @@ static DOH *encode(char *name, DOH *s) { s = tmp; pos = Tell(s); Seek(s, 0, SEEK_SET); - fn = (DOH *(*)(DOH *)) Data(handle); + *(void **)(&fn) = Data(handle); ns = (*fn) (s); assert(pos != -1); (void)Seek(s, pos, SEEK_SET);