Commit 540fa7a418c5a63557e3b36603a61a95bd296bed

Silvio 2017-03-05T16:16:16

Fix tests in Visual Studio 2015 For checking the loading of symbols from the global handle, the printf symbol was loaded, but since Visual Studio 2015 printf is defined as a inline function. To fix this, the test has been modified to load the symbol of the fwrite function.

diff --git a/test.c b/test.c
index 878694e..e7124ae 100644
--- a/test.c
+++ b/test.c
@@ -41,7 +41,6 @@
                         RETURN_ERROR;  \
                     }                  \
                 } while( 0 )
-                        
 
 /* This is what this test does:
  * - Open library with RTLD_GLOBAL
@@ -74,7 +73,7 @@ int main()
     void *library;
     char *error;
     int (*function)( void );
-    int (*printf_local)( const char * );
+    size_t (*fwrite_local) ( const void *, size_t, size_t, FILE * );
     int (*nonexistentfunction)( void );
     int ret;
 
@@ -108,8 +107,8 @@ int main()
     else
         printf( "SUCCESS\tGot global handle: %p\n", global );
 
-    printf_local = dlsym(global, "printf");
-    if (!printf_local)
+    fwrite_local = dlsym(global, "fwrite");
+    if (!fwrite_local)
     {
         error = dlerror();
         printf("ERROR\tCould not get symbol from global handle: %s\n",
@@ -119,8 +118,10 @@ int main()
         RETURN_ERROR;
     }
     else
-        printf("SUCCESS\tGot symbol from global handle: %p\n", printf_local);
-    printf_local("Hello world from local printf!\n");
+        printf("SUCCESS\tGot symbol from global handle: %p\n", fwrite_local);
+    char * hello_world = "Hello world from local fwrite!\n";
+    fwrite_local(hello_world,sizeof(char),strlen(hello_world),stderr);
+    fflush(stderr);
 
     function = dlsym( library, "function" );
     if( !function )
@@ -304,7 +305,7 @@ int main()
                 error ? error : "" );
     }
 
-    function = dlsym(global, "printf");
+    function = dlsym(global, "fwrite");
     if (!function)
     {
         error = dlerror();
@@ -316,6 +317,7 @@ int main()
     }
     else
         printf("SUCCESS\tGot symbol from global handle: %p\n", function);
+    
 
     ret = dlclose( library );
     if( ret )