Tk Source Code

View Ticket
Login
Ticket UUID: 600b72bfbc78941ba0d60aad5aa77493915ff2cd
Title: Unnecessary inclusion of tclInt.h in tkMain.c in Windows build
Type: Bug Version: 8.6.4
Submitter: apnadkarni Created on: 2015-10-06 10:35:14
Subsystem: 85. Win Build Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2015-10-06 11:51:01
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2015-10-06 11:51:01
Description:
The observation has been made on the Tcl'ers chat that Tk should be free of tclInt.h but isn't so on Windows builds.The reason it is included is the following fragment in tkMain.c

#if !defined(STATIC_BUILD)
	if (tclStubsPtr->reserved9 && TclpIsAtty) {
	    /* We are running on Cygwin */
	    return TclpIsAtty(fd);
	}
#endif

This code is in the WinIsTty function which is only defined when _WIN32 is defined.

HOWEVER

When _WIN32 is defined, reserved9 and TclpIsAtty are both hardcoded to 0 in the stubs and include file respectively. Consequently the above code is never actually "active".

This makes me think one can get rid of the above code fragment as well as inclusion of tclInt.h from tk
User Comments: jan.nijtmans added on 2015-10-06 11:51:01:

After a little bit more thinking: Fixed in [6b85af584784e8be].

Of course, the proper way would be a TIP for a new function TclIsTty() in the public API, but that will have to wait until Tcl 8.7/9.0.

Thanks for bringing this to my attenstion!


jan.nijtmans added on 2015-10-06 11:07:40:
When compiling Tcl on Cygwin (tclsh8.6.exe), it is possible to dynamically load the win32 tk86.dll into this. The effect of this is a UNIX-feel of tclsh, while the GUI is still native Windows. tk86.dll contains a few hacks (when compiled for win32) to make this work, the code you found is one of them. When tk86.dll is loaded in (Cygwin) tclsh8.6.exe, then tclStubsPtr->reserved9 is equivalent to the Tcl_CreateFileHandler() entry, which only exists on UNIX. The entry for TclpIsAtty() is specially added to Tcl for Cygwin support, so Tk can check if the tclsh8.6.exe is new enough to support this feature.

Hence, I would like to keep this code. But if you see a way to eliminate the need for tclInt.h, that would be great.