Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tkinter fails to build with Tcl 9.0 due to Tcl_AppInit() undeclared #104363

Open
Tracked by #104568
chrstphrchvz opened this issue May 10, 2023 · 3 comments
Open
Tracked by #104568

Tkinter fails to build with Tcl 9.0 due to Tcl_AppInit() undeclared #104363

chrstphrchvz opened this issue May 10, 2023 · 3 comments
Assignees

Comments

@chrstphrchvz
Copy link
Contributor

chrstphrchvz commented May 10, 2023

Since Tcl 8.0.5 (tcltk/tcl@17481a9), tcl.h has clarified that Tcl_AppInit() is not an exported Tcl library function, and declares Tcl_AppInit() for compatibility/convenience only:

/*
 *----------------------------------------------------------------------------
 * Convenience declaration of Tcl_AppInit for backwards compatibility. This
 * function is not *implemented* by the tcl library, so the storage class is
 * neither DLLEXPORT nor DLLIMPORT.
 */

extern Tcl_AppInitProc Tcl_AppInit;

This declaration is deprecated in Tcl 8.7 and removed in Tcl 9.0. Without it, _tkinter.c will fail to build if the compiler treats implicit function declarations as errors:

./Modules/_tkinter.c:713:9: error: call to undeclared function 'Tcl_AppInit'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
    if (Tcl_AppInit(v->interp) != TCL_OK) {
        ^
./Modules/_tkinter.c:713:9: note: did you mean 'Tcl_Init'?
/Users/user/tcl90p/include/tclDecls.h:513:13: note: 'Tcl_Init' declared here
EXTERN int              Tcl_Init(Tcl_Interp *interp);
                        ^

Although it seems possible to have _tkinter.c declare Tcl_AppInit() when tcl.h does not, I am not familiar enough with Tcl_AppInit() usage to know whether that is a good solution. From reading the Tcl_AppInit() documentation, it sounds like Tkinter could instead rename its Tcl_AppInit() in tkappinit.c to something else, which it then always declares in _tkinter.c.

@terryjreedy
Copy link
Member

@serhiy-storchaka This issue is about patching _tkinter.

@serhiy-storchaka
Copy link
Member

I agree with the analysis of @chrstphrchvz. I came to the same two possible quick solutions, and I also not qualified to decide what is better.

For now, it looks safer to add the missing declaration of Tcl_AppInit:

#if TK_MAJOR_VERSION >= 9
int Tcl_AppInit(Tcl_Interp *);
#endif

If the user code uses an embedded Python or a custom build of Python with statically linked Tcl/Tk and third-party binary Tcl/Tk libraries, they will still be able to define a custom Tcl_AppInit().

In future we may implement more modern approach, but this minimum is necessary to build Tkinter with Tcl/Tk 9.0.

I'll add this change in #112681 because both changes are needed to unblock a build.

@serhiy-storchaka
Copy link
Member

Tkinter builds now with Tcl 9.0. I leave this issue open for the case if we find better solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants