cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: how do we remove this annoying gcc warning?

From: Joe Halpin <j.p.h_at_comcast.net>
Date: Wed, 05 May 2004 09:04:19 -0500

Daniel Stenberg wrote:
> Hi friends
>
> Since I installed gcc 3.4.0 on one of my linux hosts do autobuilds, I get a
> warning on all builds. See this one:
>
> http://curl.haxx.se/auto/log.cgi?id=20040505112222-1828#prob1
>
> Anyone has any good suggestion on how the code would do to avoid this warning?
> If the code can't be changed, is there a gcc warning option we can add/remove
> to prevent this from polluting the autobuild logs?
>

This is one of those really weird situations where POSIX and C disagree
with each other C forbids the conversion and POSIX requires it to be
valid. However, I ran across an example that eliminates the warning. I
guess we have to hope we never wind up on a platform that really has
data pointers that are incompatible with function pointers.

Index: lib/ldap.c
===================================================================
RCS file: /repository/curl/lib/ldap.c,v
retrieving revision 1.35
diff -u -r1.35 ldap.c
--- lib/ldap.c 3 May 2004 15:01:34 -0000 1.35
+++ lib/ldap.c 5 May 2004 14:03:37 -0000
@@ -164,7 +164,7 @@

  #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
    if (libldap) {
- func = (dynafunc)dlsym(libldap, name);
+ *(void**) (&func) = dlsym(libldap, name);
    }
  #elif defined(WIN32)
    if (libldap) {

Joe
Received on 2004-05-05