Changeset 825966 in git


Ignore:
Timestamp:
Feb 22, 2012, 7:37:52 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
1ffd5aaa7f73b96e691b67a5fb6a364a7dfb77d1
Parents:
9840b5050e1851feb2d68a4b74113aa1b59fa12d
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-02-22 19:37:52+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-02-23 20:35:08+01:00
Message:
function-to-function/object warnings

fix the warnings using a union hack (misc/auxiliary.h.in)

NOTE: this is a C/C++-standard issue, see http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
Location:
libpolys
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libpolys/misc/auxiliary.h.in

    r9840b5 r825966  
    426426#endif
    427427
     428#ifdef __cplusplus
     429// hack to workaround warnings when casting void pointers
     430// retrieved from dlsym? to function pointers.
     431// see: http://trac.osgeo.org/qgis/ticket/234, http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
     432template<typename A, typename B>
     433inline B cast_A_to_B( A a )
     434{
     435  union
     436  {
     437    A a;
     438    B b;
     439  } u;
     440
     441  u.a = a;
     442  return u.b;
     443}
     444
     445template<typename A>
     446inline void* cast_A_to_vptr( A a )
     447{
     448  return cast_A_to_B<A, void*>(a);
     449}
     450
     451
     452template<typename A>
     453inline A cast_vptr_to_A( void * p )
     454{
     455  return cast_A_to_B<void*, A>(p);
     456}
     457#endif
     458
    428459
    429460
  • libpolys/polys/templates/p_Procs_Dynamic.cc

    r9840b5 r825966  
    9494  {
    9595      case p_Copy_Proc:
    96         return (void *)p_Copy__FieldGeneral_LengthGeneral_OrdGeneral;
     96        return cast_A_to_vptr(p_Copy__FieldGeneral_LengthGeneral_OrdGeneral);
    9797      case p_Delete_Proc:
    98         return (void *)p_Delete__FieldGeneral_LengthGeneral_OrdGeneral;
     98        return cast_A_to_vptr(p_Delete__FieldGeneral_LengthGeneral_OrdGeneral);
    9999      case p_ShallowCopyDelete_Proc:
    100         return (void *)p_ShallowCopyDelete__FieldGeneral_LengthGeneral_OrdGeneral;
     100        return cast_A_to_vptr(p_ShallowCopyDelete__FieldGeneral_LengthGeneral_OrdGeneral);
    101101      case p_Mult_nn_Proc:
    102         return (void *)p_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral;
     102        return cast_A_to_vptr(p_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral);
    103103      case pp_Mult_nn_Proc:
    104         return (void *)pp_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral;
     104        return cast_A_to_vptr(pp_Mult_nn__FieldGeneral_LengthGeneral_OrdGeneral);
    105105      case pp_Mult_mm_Proc:
    106         return (void *)pp_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral;
     106        return cast_A_to_vptr(pp_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral);
    107107      case pp_Mult_mm_Noether_Proc:
    108         return (void *)pp_Mult_mm_Noether__FieldGeneral_LengthGeneral_OrdGeneral;
     108        return cast_A_to_vptr(pp_Mult_mm_Noether__FieldGeneral_LengthGeneral_OrdGeneral);
    109109      case p_Mult_mm_Proc:
    110         return (void *)p_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral;
     110        return cast_A_to_vptr(p_Mult_mm__FieldGeneral_LengthGeneral_OrdGeneral);
    111111      case p_Add_q_Proc:
    112         return (void *)p_Add_q__FieldGeneral_LengthGeneral_OrdGeneral;
     112        return cast_A_to_vptr(p_Add_q__FieldGeneral_LengthGeneral_OrdGeneral);
    113113      case p_Minus_mm_Mult_qq_Proc:
    114         return (void *)p_Minus_mm_Mult_qq__FieldGeneral_LengthGeneral_OrdGeneral;
     114        return cast_A_to_vptr(p_Minus_mm_Mult_qq__FieldGeneral_LengthGeneral_OrdGeneral);
    115115      case p_Neg_Proc:
    116         return (void *)p_Neg__FieldGeneral_LengthGeneral_OrdGeneral;
     116        return cast_A_to_vptr(p_Neg__FieldGeneral_LengthGeneral_OrdGeneral);
    117117      case pp_Mult_Coeff_mm_DivSelect_Proc:
    118         return (void *)pp_Mult_Coeff_mm_DivSelect__FieldGeneral_LengthGeneral_OrdGeneral;
     118        return cast_A_to_vptr(pp_Mult_Coeff_mm_DivSelect__FieldGeneral_LengthGeneral_OrdGeneral);
    119119      case pp_Mult_Coeff_mm_DivSelectMult_Proc:
    120         return (void *)pp_Mult_Coeff_mm_DivSelectMult__FieldGeneral_LengthGeneral_OrdGeneral;
     120        return cast_A_to_vptr(pp_Mult_Coeff_mm_DivSelectMult__FieldGeneral_LengthGeneral_OrdGeneral);
    121121      case p_Merge_q_Proc:
    122         return (void *)p_Merge_q__FieldGeneral_LengthGeneral_OrdGeneral;
     122        return cast_A_to_vptr(p_Merge_q__FieldGeneral_LengthGeneral_OrdGeneral);
    123123      case p_kBucketSetLm_Proc:
    124         return (void *)p_kBucketSetLm__FieldGeneral_LengthGeneral_OrdGeneral;
     124        return cast_A_to_vptr(p_kBucketSetLm__FieldGeneral_LengthGeneral_OrdGeneral);
    125125      case p_Unknown_Proc:
    126126        break;
     
    218218
    219219#define DoReallySetProc(what, field, length, ord)           \
    220   _p_procs->what = (what##_Proc_Ptr)                        \
    221      GetDynamicProc(#what, what##_Proc, field, length, ord)
     220  _p_procs->what =    cast_vptr_to_A<what##_Proc_Ptr>(      \
     221     GetDynamicProc(#what, what##_Proc, field, length, ord))
    222222
    223223#ifdef RDEBUG
     
    226226{                                                                   \
    227227  if (set_names)                                                    \
    228     _p_procs->what = (what##_Proc_Ptr)                              \
    229        GetDynamicProc(#what,  what##_Proc, field, length, ord, 1);  \
     228    _p_procs->what =    cast_vptr_to_A<what##_Proc_Ptr>(            \
     229       GetDynamicProc(#what,  what##_Proc, field, length, ord, 1));  \
    230230  else                                                              \
    231231    DoReallySetProc(what, field, length, ord);                      \
  • libpolys/polys/templates/p_Procs_Set.h

    r9840b5 r825966  
    126126#endif
    127127
     128// (which##_Proc_Ptr)F ->-> cast_vptr_to_A<which##_Proc_Ptr>(F)?
    128129#define CheckProc(which)                                    \
    129130do                                                          \
     
    134135    WarnS("Singular will work properly, but much slower");  \
    135136    WarnS("If you chose a coef ring, it may not work at all");\
    136     p_Procs->which = (which##_Proc_Ptr)                     \
    137       which##__FieldGeneral_LengthGeneral_OrdGeneral;       \
     137    p_Procs->which =                 (which##_Proc_Ptr)(    \
     138      which##__FieldGeneral_LengthGeneral_OrdGeneral);       \
    138139  }                                                         \
    139140}                                                           \
  • libpolys/polys/templates/p_Procs_Static.cc

    r9840b5 r825966  
    4141// define DoSetProc and InitSetProcs
    4242#define SetStaticProcFromArray(what, type, field, length, ord) \
    43   _p_procs->what = (what##_Proc_Ptr) \
    44     what##_Proc_##type [index(what##_Proc, field, length, ord)]
     43  _p_procs->what =            cast_vptr_to_A<what##_Proc_Ptr>( \
     44    what##_Proc_##type [index(what##_Proc, field, length, ord)])
    4545
    4646#define SetStaticProcFromFuncsArray(what, field, length, ord) \
Note: See TracChangeset for help on using the changeset viewer.