X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com X-Authenticated: #27081556 X-Provags-ID: V01U2FsdGVkX1/k4MkWdVbkyLCkHJ3r735iljqPsuE4Yfo9AoaNw0 MiTBaLFgfC1vTo Message-ID: <50DE0807.3090608@gmx.de> Date: Fri, 28 Dec 2012 21:58:47 +0100 From: Juan Manuel Guerrero User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2 MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Fixing test-cases (patch 1/2) Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Reply-To: djgpp-workers AT delorie DOT com The patch below will fix the warning: ISO C forbids conversion of function pointer to object pointer type [-pedantic] ISO C++ forbids casting between pointer-to-function and pointer-to-object [enabled by default] in /tests/dxe. Regards, Juan M. Guerrero diff -aprNU5 djgpp.orig/tests/dxe/dldemo.cpp djgpp/tests/dxe/dldemo.cpp --- djgpp.orig/tests/dxe/dldemo.cpp 2005-01-15 19:18:48 +0000 +++ djgpp/tests/dxe/dldemo.cpp 2012-12-28 21:03:34 +0000 @@ -41,11 +41,17 @@ static int lastresort () } void *dxe_res (const char *symname) { printf ("%s: undefined symbol in dynamic module\n", symname); - return (void *)lastresort; + + union { + int (*from)(void); + void *to; + } func_ptr_cast; + func_ptr_cast.from = lastresort; + return func_ptr_cast.to; } int main () { // Set the error callback function @@ -75,11 +81,16 @@ int main () int *x_counter = (int *)dlsym (h1, "_x_counter"); if (x_counter) *x_counter += 50; // Allright, now call the main function from second module - void (*test_reexp) () = (void (*)())dlsym (h2, "_test_reexp"); + union { + void *from; + void (*to)(void); + } func_ptr_cast; + func_ptr_cast.from = dlsym (h2, "_test_reexp"); + void (*test_reexp)() = func_ptr_cast.to; if (test_reexp) test_reexp (); dlclose (h2); dlclose (h1); diff -aprNU5 djgpp.orig/tests/dxe/dlsimp.cpp djgpp/tests/dxe/dlsimp.cpp --- djgpp.orig/tests/dxe/dlsimp.cpp 2003-04-23 06:39:14 +0000 +++ djgpp/tests/dxe/dlsimp.cpp 2012-12-28 21:03:34 +0000 @@ -22,11 +22,16 @@ int main () { printf (MODULE ": %s\n", dlerror ()); exit (-1); } - int (*my_strlen) (const char *) = (int (*) (const char *))dlsym (h, "_my_strlen"); + union { + void *from; + int (*to)(const char *); + } func_ptr_cast; + func_ptr_cast.from = dlsym (h, "_my_strlen"); + int (*my_strlen)(const char *) = func_ptr_cast.to; printf ("my_strlen (\"abcde\") = %d\n", my_strlen ("abcde")); dlclose (h); return 0; diff -aprNU5 djgpp.orig/tests/dxe/test2.cpp djgpp/tests/dxe/test2.cpp --- djgpp.orig/tests/dxe/test2.cpp 2003-04-23 06:39:14 +0000 +++ djgpp/tests/dxe/test2.cpp 2012-12-28 21:03:34 +0000 @@ -35,11 +35,16 @@ extern "C" int test_func () throw exception(); } catch (exception e) { e.handle(); } #endif - printf ("hello world! (&extern_func = %p)\n", (void *)(&extern_func)); + union { + void (*from)(void); + void *to; + } func_ptr_cast; + func_ptr_cast.from = extern_func; + printf ("hello world! (&extern_func = %p)\n", func_ptr_cast.to); return 0; } int x_counter = 0;