lua-users home
lua-l archive

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


On Fri, Jan 08, 2010 at 11:54:34AM -0200, Roberto Ierusalimschy wrote:
> > I'll admit that the casting chain isn't pretty; but it is reliable
> > as far as I can tell.
> 
> Generally, this construction is not reliable:

POSIX recommends this approach to avoid the conversion warning:

  int (*fptr)(int);
  *(void**)(&fptr) = dlsym(handle,"my_function");

This is undefined in pure C, but dlsym is part of the POSIX XSI
extension and on an XSI-conforming system the conversions are required
to be defined.  You can find the IEEE discussion of the issue at:

  http://standards.ieee.org/reading/ieee/interp/1003.1-2001/1003.1-2001-03.html

                                                  -Dave Dodge