Posted to tcl by apn at Mon Mar 20 06:06:36 GMT 2023view raw
- The sample below builds with 8.7 and 9.0 with no warnings. However it does not make full functionality of 9.0 as len is 32-bits.
- int
- Sandbox_Cmd(
- ClientData dummy, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter */
- int objc, /* Number of arguments */
- Tcl_Obj *const objv[] /* Argument strings */
- )
- {
- int len;
- Tcl_Obj *parts;
- parts = Tcl_FSSplitPath(objv[1], &len);
- Tcl_DecrRefCount(parts); /* Assume non-null */
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj(len));
- return TCL_OK;
- }
- To make full 64-bit support on 9.0, the len variable type needs to be size_t.
- int
- Sandbox_Cmd(
- ClientData dummy, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter */
- int objc, /* Number of arguments */
- Tcl_Obj *const objv[] /* Argument strings */
- )
- {
- size_t len;
- Tcl_Obj *parts;
- parts = Tcl_FSSplitPath(objv[1], &len);
- Tcl_DecrRefCount(parts); /* Assume non-null */
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj(len));
- return TCL_OK;
- }
- This now however results in compiler warnings with 8.7.
- D:\src\sampleextension\win\..\generic\tclsample.c(343): warning C4133: 'function': incompatible types - from 'size_t *' to 'int *'
- Moreover, if the warning is ignored, the function will fail miserably on bigendian machines.