Re: Avoiding compiler warnings/errors with function pointers

2007-06-11 Thread Reuben Thomas

On Tue, 5 Jun 2007, Peter O'Gorman wrote:


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...:
http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libc/gen/dlfunc.c?rev=1.3;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.


I am on Linux, where I can't see a similar function.

--
http://rrt.sc3d.org/ | think tank, n.  a safe container for noxious gases


___
http://lists.gnu.org/mailman/listinfo/libtool


Re: Avoiding compiler warnings/errors with function pointers

2007-06-11 Thread Peter O'Gorman


On Jun 11, 2007, at 12:34 PM, Reuben Thomas wrote:


On Tue, 5 Jun 2007, Peter O'Gorman wrote:


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...:
http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libc/gen/ 
dlfunc.c?rev=1.3;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.


I am on Linux, where I can't see a similar function.



Hi Reuben,
When I reread your email I see my mistake. You can not avoid the  
warning altogether, somewhere there has to be code that will warn,  
FreeBSD chose to move that bit of code into libc, you could similarly  
choose to move the warning code to one file and turn off the strict  
compilation for that file.


Sorry for misleading.

Peter
--
Peter O'Gorman
http://pogma.com




___
http://lists.gnu.org/mailman/listinfo/libtool


Avoiding compiler warnings/errors with function pointers

2007-06-05 Thread Reuben Thomas

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?

--
http://rrt.sc3d.org/ | resident, a.  unable to leave (Bierce)


___
http://lists.gnu.org/mailman/listinfo/libtool


Re: Avoiding compiler warnings/errors with function pointers

2007-06-05 Thread Gary V. Vaughan

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 :-(

Cheers,
Gary
--
  ())_.  Email me: [EMAIL PROTECTED]
  ( '/   Read my blog: http://blog.azazil.net
  / )= ...and my book: http://sources.redhat.com/autobook
`(_~)_ Join my AGLOCO Network: http://www.agloco.com/r/BBBS7912






PGP.sig
Description: This is a digitally signed message part
___
http://lists.gnu.org/mailman/listinfo/libtool


Re: Avoiding compiler warnings/errors with function pointers

2007-06-05 Thread Peter O'Gorman
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...:
http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libc/gen/dlfunc.c?rev=1.3;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.

Peter


___
http://lists.gnu.org/mailman/listinfo/libtool