[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding compiler warnings/errors with function pointers

From: Peter O'Gorman
Subject: Re: Avoiding compiler warnings/errors with function pointers
Date: Tue, 05 Jun 2007 11:56:44 -0500

On Tue, 2007-06-05 at 17:08 +0100, Gary V. Vaughan wrote:
> He Reuben,
> On 4 Jun 2007, at 09:55, Reuben Thomas wrote:
> > I have a line of code like this:
> >
> >    if ((l_fn = lt_dlsym(l_st->lth, "ladspa_descriptor")) == NULL) {
> >
> > where l_fn is a function pointer. gcc says:
> >
> > ladspa.c: In function 'sox_ladspa_getopts':
> > ladspa.c:114: warning: ISO C forbids assignment between function  
> > pointer and 'void *'
> >
> > There's no problem with this on my machine with my compiler  
> > settings, but if I wanted to write strictly conforming ISO C it  
> > looks like I'd have a problem; equally if I wanted this code to run  
> > on a machine where void * was not compatible with a function pointer.
> >
> > Is there some way to avoid this problem?
> What type does dlsym() return on that system?
> If it is a void*, then I don't know of any portable way around it :-(

freeBSD has a dlfunc() function that behaves like dlsym but returns a
function pointer, last time I looked it was implemented using a union...
wait, let me look again...:;content-type=text%2Fplain

I think it is even in our TODO to have libltdl do this somehow, in the
meantime, Reuben can do something similar in his own code.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]