Title: Tkinter: incompatible pointer types warnings when built with Tcl 9 · Issue #112672 · python/cpython · GitHub
Open Graph Title: Tkinter: incompatible pointer types warnings when built with Tcl 9 · Issue #112672 · python/cpython
X Title: Tkinter: incompatible pointer types warnings when built with Tcl 9 · Issue #112672 · python/cpython
Description: Tcl/Tk 9 changes C APIs to use a different type for sizes to allow transferring ≥32-bit sized things. The new type is Tcl_Size, which as of TIP 660 is defined as either ptrdiff_t in Tcl 9, or int in Tcl 8.7 for binary compatibility. My i...
Open Graph Description: Tcl/Tk 9 changes C APIs to use a different type for sizes to allow transferring ≥32-bit sized things. The new type is Tcl_Size, which as of TIP 660 is defined as either ptrdiff_t in Tcl 9, or int i...
X Description: Tcl/Tk 9 changes C APIs to use a different type for sizes to allow transferring ≥32-bit sized things. The new type is Tcl_Size, which as of TIP 660 is defined as either ptrdiff_t in Tcl 9, or int i...
Opengraph URL: https://github.com/python/cpython/issues/112672
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tkinter: incompatible pointer types warnings when built with Tcl 9","articleBody":"Tcl/Tk 9 changes C APIs to use a different type for sizes to allow transferring ≥32-bit sized things. The new type is `Tcl_Size`, which as of [TIP 660](https://core.tcl-lang.org/tips/doc/trunk/tip/660.md) is defined as either `ptrdiff_t` in Tcl 9, or `int` in Tcl 8.7 for binary compatibility.\r\n\r\nMy impression is that Tcl/Tk wrappers such as Tkinter, which are primarily used for Tk GUI, have little if any need for this. But as of [TIP 664](https://core.tcl-lang.org/tips/doc/trunk/tip/664.md), usage of APIs which previously expected `int *` must be updated for Tcl 9. There was previously effort in Tcl to continue allowing `int *` usage for compatibility, and maybe that would have been good enough for Tkinter, but others in the Tcl/Tk inner circle (who already wish to abandon Tcl/Tk \u003c 9 entirely) rejected that approach. `-Wincompatible-pointer-types` warnings now seen under Tcl 9:\r\n\r\n```\r\n./Modules/_tkinter.c:504:21: warning: incompatible pointer types passing 'int *' to parameter of type 'Tcl_Size *' (aka 'long *') [-Wincompatible-pointer-types]\r\n 504 | const char *s = Tcl_GetStringFromObj(value, \u0026len);\r\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\ntcl90/include/tclDecls.h:4235:36: note: expanded from macro 'Tcl_GetStringFromObj'\r\n 4235 | (Tcl_GetStringFromObj)((objPtr), (sizePtr)))\r\n | ^~~~~~~~~\r\ntcl90/include/tclDecls.h:1754:15: note: passing argument to parameter 'lengthPtr' here\r\n 1754 | Tcl_Size *lengthPtr);\r\n | ^\r\n./Modules/_tkinter.c:1138:29: warning: incompatible pointer types passing 'int *' to parameter of type 'Tcl_Size *' (aka 'long *') [-Wincompatible-pointer-types]\r\n 1138 | char *data = (char*)Tcl_GetByteArrayFromObj(value, \u0026size);\r\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\ntcl90/include/tclDecls.h:4229:41: note: expanded from macro 'Tcl_GetByteArrayFromObj'\r\n 4229 | (Tcl_GetBytesFromObj)(NULL, (objPtr), (sizePtr)))\r\n | ^~~~~~~~~\r\ntcl90/include/tclDecls.h:1751:32: note: passing argument to parameter 'numBytesPtr' here\r\n 1751 | Tcl_Obj *objPtr, Tcl_Size *numBytesPtr);\r\n | ^\r\n./Modules/_tkinter.c:1168:18: warning: incompatible pointer types passing 'int *' to parameter of type 'Tcl_Size *' (aka 'long *') [-Wincompatible-pointer-types]\r\n 1168 | status = Tcl_ListObjLength(interp, value, \u0026size);\r\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\ntcl90/include/tclDecls.h:4244:44: note: expanded from macro 'Tcl_ListObjLength'\r\n 4244 | (Tcl_ListObjLength)((interp), (listPtr), (lengthPtr)))\r\n | ^~~~~~~~~~~\r\ntcl90/include/tclDecls.h:1790:33: note: passing argument to parameter 'lengthPtr' here\r\n 1790 | Tcl_Obj *listPtr, Tcl_Size *lengthPtr);\r\n | ^\r\n./Modules/_tkinter.c:2104:13: warning: incompatible pointer types passing 'int *' to parameter of type 'Tcl_Size *' (aka 'long *') [-Wincompatible-pointer-types]\r\n 2104 | if (Tcl_ListObjGetElements(Tkapp_Interp(self),\r\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n 2105 | ((PyTclObject*)arg)-\u003evalue,\r\n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n 2106 | \u0026objc, \u0026objv) == TCL_ERROR) {\r\n | ~~~~~~~~~~~~~\r\ntcl90/include/tclDecls.h:4241:49: note: expanded from macro 'Tcl_ListObjGetElements'\r\n 4241 | (Tcl_ListObjGetElements)((interp), (listPtr), (objcPtr), (objvPtr)))\r\n | ^~~~~~~~~\r\ntcl90/include/tclDecls.h:1786:33: note: passing argument to parameter 'objcPtr' here\r\n 1786 | Tcl_Obj *listPtr, Tcl_Size *objcPtr,\r\n | ^\r\n./Modules/_tkinter.c:2136:9: warning: incompatible pointer types passing 'int *' to parameter of type 'Tcl_Size *' (aka 'long *') [-Wincompatible-pointer-types]\r\n 2136 | if (Tcl_SplitList(Tkapp_Interp(self), list,\r\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n 2137 | \u0026argc, \u0026argv) == TCL_ERROR) {\r\n | ~~~~~~~~~~~~~\r\ntcl90/include/tclDecls.h:4250:40: note: expanded from macro 'Tcl_SplitList'\r\n 4250 | (Tcl_SplitList)((interp), (listStr), (argcPtr), (argvPtr)))\r\n | ^~~~~~~~~\r\ntcl90/include/tclDecls.h:1796:36: note: passing argument to parameter 'argcPtr' here\r\n 1796 | const char *listStr, Tcl_Size *argcPtr,\r\n | ^\r\n5 warnings generated.\r\n```\r\n\r\nCode intending to remain compatible with Tcl 8.6 is suggested to use the following after including tcl.h:\r\n\r\n```\r\n#ifndef TCL_SIZE_MAX\r\ntypedef int Tcl_Size;\r\n# define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj\r\n# define Tcl_NewSizeIntObj Tcl_NewIntObj\r\n# define TCL_SIZE_MAX INT_MAX\r\n# define TCL_SIZE_MODIFIER \"\"\r\n#endif\r\n```\r\n\r\nI intend to open a PR updating _tkinter.c to pass `Tcl_Size *` where needed.\r\n\r\nThere are several other instances where Tkinter assumes Tcl expects`int` or something not larger than `INT_MAX`, but migrating those to `Tcl_Size` and `TCL_SIZE_MAX` seems optional.\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-112681\r\n* gh-120208\n* gh-120209\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/chrstphrchvz","@type":"Person","name":"chrstphrchvz"},"datePublished":"2023-12-03T20:19:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/112672/cpython/issues/112672"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f9272e17-3d75-b7cc-2c44-1d35848be1d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6CC:BB754:17CD14:2124C3:696A4005 |
| html-safe-nonce | 7e5f177bd7195ac57672c17ff8f7c21be5db8a2f760557387a771de6be45aa8c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkNDOkJCNzU0OjE3Q0QxNDoyMTI0QzM6Njk2QTQwMDUiLCJ2aXNpdG9yX2lkIjoiMjE2NTU2MTMzNDYyMTE1OTQyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b8bf23d7340aed069bd6790e4dbab4d5590b3ed8521057237eff398a46aaa1ca |
| hovercard-subject-tag | issue:2022698890 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/112672/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9c67e9c42a1f73bbef4bc6e3d5c9d1e247827c424d951e46cee8f5bac645237d/python/cpython/issues/112672 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9c67e9c42a1f73bbef4bc6e3d5c9d1e247827c424d951e46cee8f5bac645237d/python/cpython/issues/112672 |
| og:image:alt | Tcl/Tk 9 changes C APIs to use a different type for sizes to allow transferring ≥32-bit sized things. The new type is Tcl_Size, which as of TIP 660 is defined as either ptrdiff_t in Tcl 9, or int i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chrstphrchvz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width