From: SourceForge.net <no...@so...> - 2012-07-18 06:26:27
|
Bugs item #3545277, was opened at 2012-07-17 23:26 Message generated for change (Tracker Item Submitted) made by fedorabug You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3545277&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: tcl Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: fedorabug (fedorabug) Assigned to: Nobody/Anonymous (nobody) Summary: Generated C code casts from void * to pointer-to-function Initial Comment: The generated C code below casts from 'void *' to a function pointer which according to GCC is not legal C code. Commands used: swig -tcl baseFunc.i gcc -x c -pedantic baseFunc_wrap.c -ltcl /* baseFunc.i */ %module baseFunc %{ #include "tclFunctions.c" %} %include "tclFunctions.h" GCC: baseFunc_wrap.c:2085:11: warning: ISO C forbids conversion of function pointer to object pointer type [-pedantic] These are the statements and declarations involved, after running the preprocessor(clang -pedantic -E baseFunc_wrap.c): typedef void *ClientData; typedef int (*swig_wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *const []); if (hashentry) { ClientData cd = ((hashentry)->clientData); swig_wrapper method_wrapper = (swig_wrapper)cd; //Invalid cast oldarg = objv[1]; objv[1] = inst->thisptr; ++(inst->thisptr)->refCount; rcode = (method_wrapper)(clientData,interp,objc,objv); objv[1] = oldarg; do { if (--(inst->thisptr)->refCount <= 0) TclFreeObj(inst->thisptr); } while(0); return rcode; } Similar warnings are given when using c++. swig -c++ -tcl baseFunc.i clang++ -pedantic baseFunc_wrap.cxx -ltcl baseFunc_wrap.cxx:2147:39: warning: cast between pointer-to-function and pointer-to-object is an extension [-pedantic] Tcl_SetHashValue(hashentry, (ClientData)meth->method); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/tcl.h:2353:69: note: expanded from macro 'Tcl_SetHashValue' #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value)) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3545277&group_id=1645 |