Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Bing, DotBot

Members: 0
Guests: 5
Stats
Files
Topics
Posts
Members
Newest Member
481
3,739
19,386
622
ignatius
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Bug: Casting void pointer to ...
Forum Rules | Mark all | Recent Posts

Bug: Casting void pointer to function pointer does not conform to ISO C
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 27, 2008, 11:53 am
Go to the top of the page
Go to the bottom of the page

Caius
Magician
GroupMembers
Posts132
JoinedJan 29, 2006

DO_FUN *skill_function( const char *name )
{
   void *funHandle;
#if !defined(WIN32)
   const char *error;
#else
   DWORD error;
#endif

   funHandle = dlsym( sysdata.dlHandle, name );
   if( ( error = dlerror(  ) ) )
   {
      bug( "Error locating %s in symbol table. %s", name, error );
      return skill_notfound;
   }
   return ( DO_FUN * ) funHandle;
}


The return value will give a warning in a compiler conforming strictly to ISO C. You can get the warning in GCC by compiling with -pedantic. For reference see here and here.

The function can be rewritten as:
DO_FUN *skill_function( const char *name )
{
   DO_FUN *funHandle;
#if !defined(WIN32)
   const char *error;
#else
   DWORD error;
#endif

   *(void**)(&funHandle) = dlsym( sysdata.dlHandle, name );
   if( ( error = dlerror(  ) ) )
   {
      bug( "Error locating %s in symbol table. %s", name, error );
      return skill_notfound;
   }
   return funHandle;
}

This is based on the example in the second link. As a disclaimer I have to mention that I don't have a Win32 environment to test this with.
       
Pages:<< prev 1 next >>