Index: libpolys/misc/auxiliary.h.in
===================================================================
--- libpolys/misc/auxiliary.h.in	(revision 9840b5050e1851feb2d68a4b74113aa1b59fa12d)
+++ libpolys/misc/auxiliary.h.in	(revision 825966911e14a0eecc7a3e639cd2e99e210c18e2)
@@ -426,4 +426,35 @@
 #endif
 
+#ifdef __cplusplus
+// hack to workaround warnings when casting void pointers
+// retrieved from dlsym? to function pointers.
+// see: http://trac.osgeo.org/qgis/ticket/234, http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
+template<typename A, typename B>
+inline B cast_A_to_B( A a )
+{
+  union
+  {
+    A a;
+    B b;
+  } u;
+
+  u.a = a;
+  return u.b;
+}
+
+template<typename A>
+inline void* cast_A_to_vptr( A a )
+{
+  return cast_A_to_B<A, void*>(a);
+}
+
+
+template<typename A>
+inline A cast_vptr_to_A( void * p )
+{
+  return cast_A_to_B<void*, A>(p);
+}
+#endif
+
 
 
Index: libpolys/polys/templates/p_Procs_Dynamic.cc
===================================================================
--- libpolys/polys/templates/p_Procs_Dynamic.cc	(revision 9840b5050e1851feb2d68a4b74113aa1b59fa12d)
+++ libpolys/polys/templates/p_Procs_Dynamic.cc	(revision 825966911e14a0eecc7a3e639cd2e99e210c18e2)
@@ -94,33 +94,33 @@
   {
       case p_Copy_Proc:
-        return (void *)p_Copy__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Copy__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Delete_Proc:
-        return (void *)p_Delete__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Delete__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_ShallowCopyDelete_Proc:
-        return (void *)p_ShallowCopyDelete__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_ShallowCopyDelete__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Mult_nn_Proc:
-        return (void *)p_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral);
       case pp_Mult_nn_Proc:
-        return (void *)pp_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(pp_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral);
       case pp_Mult_mm_Proc:
-        return (void *)pp_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(pp_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral);
       case pp_Mult_mm_Noether_Proc:
-        return (void *)pp_Mult_mm_Noether__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(pp_Mult_mm_Noether__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Mult_mm_Proc:
-        return (void *)p_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Add_q_Proc:
-        return (void *)p_Add_q__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Add_q__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Minus_mm_Mult_qq_Proc:
-        return (void *)p_Minus_mm_Mult_qq__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Minus_mm_Mult_qq__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Neg_Proc:
-        return (void *)p_Neg__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Neg__FieldGeneral_LengthGeneral_OrdGeneral);
       case pp_Mult_Coeff_mm_DivSelect_Proc:
-        return (void *)pp_Mult_Coeff_mm_DivSelect__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(pp_Mult_Coeff_mm_DivSelect__FieldGeneral_LengthGeneral_OrdGeneral);
       case pp_Mult_Coeff_mm_DivSelectMult_Proc:
-        return (void *)pp_Mult_Coeff_mm_DivSelectMult__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(pp_Mult_Coeff_mm_DivSelectMult__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Merge_q_Proc:
-        return (void *)p_Merge_q__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_Merge_q__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_kBucketSetLm_Proc:
-        return (void *)p_kBucketSetLm__FieldGeneral_LengthGeneral_OrdGeneral;
+        return cast_A_to_vptr(p_kBucketSetLm__FieldGeneral_LengthGeneral_OrdGeneral);
       case p_Unknown_Proc:
         break;
@@ -218,6 +218,6 @@
 
 #define DoReallySetProc(what, field, length, ord)           \
-  _p_procs->what = (what##_Proc_Ptr)                        \
-     GetDynamicProc(#what, what##_Proc, field, length, ord)
+  _p_procs->what =    cast_vptr_to_A<what##_Proc_Ptr>(      \
+     GetDynamicProc(#what, what##_Proc, field, length, ord))
 
 #ifdef RDEBUG
@@ -226,6 +226,6 @@
 {                                                                   \
   if (set_names)                                                    \
-    _p_procs->what = (what##_Proc_Ptr)                              \
-       GetDynamicProc(#what,  what##_Proc, field, length, ord, 1);  \
+    _p_procs->what =    cast_vptr_to_A<what##_Proc_Ptr>(            \
+       GetDynamicProc(#what,  what##_Proc, field, length, ord, 1));  \
   else                                                              \
     DoReallySetProc(what, field, length, ord);                      \
Index: libpolys/polys/templates/p_Procs_Set.h
===================================================================
--- libpolys/polys/templates/p_Procs_Set.h	(revision 9840b5050e1851feb2d68a4b74113aa1b59fa12d)
+++ libpolys/polys/templates/p_Procs_Set.h	(revision 825966911e14a0eecc7a3e639cd2e99e210c18e2)
@@ -126,4 +126,5 @@
 #endif
 
+// (which##_Proc_Ptr)F ->-> cast_vptr_to_A<which##_Proc_Ptr>(F)?
 #define CheckProc(which)                                    \
 do                                                          \
@@ -134,6 +135,6 @@
     WarnS("Singular will work properly, but much slower");  \
     WarnS("If you chose a coef ring, it may not work at all");\
-    p_Procs->which = (which##_Proc_Ptr)                     \
-      which##__FieldGeneral_LengthGeneral_OrdGeneral;       \
+    p_Procs->which =                 (which##_Proc_Ptr)(    \
+      which##__FieldGeneral_LengthGeneral_OrdGeneral);       \
   }                                                         \
 }                                                           \
Index: libpolys/polys/templates/p_Procs_Static.cc
===================================================================
--- libpolys/polys/templates/p_Procs_Static.cc	(revision 9840b5050e1851feb2d68a4b74113aa1b59fa12d)
+++ libpolys/polys/templates/p_Procs_Static.cc	(revision 825966911e14a0eecc7a3e639cd2e99e210c18e2)
@@ -41,6 +41,6 @@
 // define DoSetProc and InitSetProcs
 #define SetStaticProcFromArray(what, type, field, length, ord) \
-  _p_procs->what = (what##_Proc_Ptr) \
-    what##_Proc_##type [index(what##_Proc, field, length, ord)]
+  _p_procs->what =            cast_vptr_to_A<what##_Proc_Ptr>( \
+    what##_Proc_##type [index(what##_Proc, field, length, ord)])
 
 #define SetStaticProcFromFuncsArray(what, field, length, ord) \
