Posted to tcl by apn at Mon Mar 20 06:06:36 GMT 2023view raw

  1. 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.
  2.  
  3. int
  4. Sandbox_Cmd(
  5. ClientData dummy, /* Not used. */
  6. Tcl_Interp *interp, /* Current interpreter */
  7. int objc, /* Number of arguments */
  8. Tcl_Obj *const objv[] /* Argument strings */
  9. )
  10. {
  11. int len;
  12. Tcl_Obj *parts;
  13. parts = Tcl_FSSplitPath(objv[1], &len);
  14. Tcl_DecrRefCount(parts); /* Assume non-null */
  15. Tcl_SetObjResult(interp, Tcl_NewWideIntObj(len));
  16. return TCL_OK;
  17. }
  18.  
  19. To make full 64-bit support on 9.0, the len variable type needs to be size_t.
  20.  
  21. int
  22. Sandbox_Cmd(
  23. ClientData dummy, /* Not used. */
  24. Tcl_Interp *interp, /* Current interpreter */
  25. int objc, /* Number of arguments */
  26. Tcl_Obj *const objv[] /* Argument strings */
  27. )
  28. {
  29. size_t len;
  30. Tcl_Obj *parts;
  31. parts = Tcl_FSSplitPath(objv[1], &len);
  32. Tcl_DecrRefCount(parts); /* Assume non-null */
  33. Tcl_SetObjResult(interp, Tcl_NewWideIntObj(len));
  34. return TCL_OK;
  35. }
  36.  
  37. This now however results in compiler warnings with 8.7.
  38.  
  39. D:\src\sampleextension\win\..\generic\tclsample.c(343): warning C4133: 'function': incompatible types - from 'size_t *' to 'int *'
  40.  
  41. Moreover, if the warning is ignored, the function will fail miserably on bigendian machines.
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.