Mail Archives: djgpp-workers/2012/12/28/15:58:44
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;
- Raw text -