aboutsummaryrefslogtreecommitdiff
path: root/testdll2.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2019-07-25 20:34:46 +0200
committerPali Rohár <pali.rohar@gmail.com>2019-07-25 20:34:46 +0200
commit2bb5f487922aa908d27175c5a562d34f4c6197d9 (patch)
treed3daeb4830007336d5758022ebfe3baa6bbac7e8 /testdll2.c
parent403b240f298d2a9f85c76299f6da8750263fd43b (diff)
downloaddlfcn-win32-2bb5f487922aa908d27175c5a562d34f4c6197d9.tar.gz
dlfcn-win32-2bb5f487922aa908d27175c5a562d34f4c6197d9.tar.bz2
dlfcn-win32-2bb5f487922aa908d27175c5a562d34f4c6197d9.zip
Fix gcc warning: ISO C forbids return between function pointer and void *
Instead of using compiler specific pragma to disable particular warning, rewrite code which cast from function pointer to data pointer according to POSIX dlopen() documentation. This also fix compile warning under MSVC. According to the ISO C standard, casting between function pointers and 'void *', as done above, produces undefined results. POSIX.1-2003 and POSIX.1-2008 accepted this state of affairs and proposed the following workaround: *(void **) (&cosine) = dlsym(handle, "cos"); This (clumsy) cast conforms with the ISO C standard and will avoid any compiler warnings.
Diffstat (limited to 'testdll2.c')
-rw-r--r--testdll2.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/testdll2.c b/testdll2.c
index 910c820..71d385a 100644
--- a/testdll2.c
+++ b/testdll2.c
@@ -38,7 +38,7 @@ EXPORT int function2( void )
38 char *error; 38 char *error;
39 int (*function2_orig)(void); 39 int (*function2_orig)(void);
40 printf( "Hello, world! from wrapper library\n" ); 40 printf( "Hello, world! from wrapper library\n" );
41 function2_orig = dlsym(RTLD_NEXT, "function2"); 41 *(void **) (&function2_orig) = dlsym( RTLD_NEXT, "function2" );
42 if (!function2_orig) 42 if (!function2_orig)
43 { 43 {
44 error = dlerror( ); 44 error = dlerror( );