| Description: |
OriginalBugID: 3358 Bug
Version: 8.2.1
SubmitDate: '1999-11-05'
LastModified: '2000-01-25'
Severity: MED
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 3647
OS: Windows 95
ClosedDate: '2000-01-25'
Name:
Jan Nijtmans
ReproducibleScript:
When compiling Tk8.2.1 as static library on Windows, a few problems show
up.
- The function TkWinXInit() needs to be called upon initialization. Of
course it
is possible to add this call to tclAppInit.c, but it would be more
consistant
(read: platform-independant) if the library took care of that (as Tcl
does).
- The function DllMain() is included in the static library, which is a
problem
when trying to link the library in another dll. Taking it out is not
possible, because TkWinGetPlatformId() is in the same file.
Solution: move TkWinGetPlatformID() to tkWinX.c, which would
be a more logical place anyway. Then tkWin32Dll.c can be
left out of the static library.
- gcc 2.95 uses the DllMain function, not DllEntryPoint (as VC++).
Why not combine the DllMain and DllEntryPoint functions to a
single one? For Borland, a macro suffices to handle the name
difference.
Patch:
*** generic/tkWindow.c.origWed Apr 21 23:53:28 1999
--- generic/tkWindow.cSat Sep 25 19:39:12 1999
***************
*** 21,26 ****
--- 21,29 ----
#if !defined(__WIN32__) && !defined(MAC_TCL)
#include "tkUnixInt.h"
#endif
+ #if defined(__WIN32__)
+ #include "tkWinInt.h"
+ #endif
typedef struct ThreadSpecificData {
***************
*** 2709,2714 ****
--- 2712,2727 ----
Tcl_DString class;
ThreadSpecificData *tsdPtr;
+ #if defined(__WIN32__) && defined(STATIC_BUILD) && !defined(NO_STATIC_INIT)
+ /*
+ * If we are in a statically linked executable, then we need to
+ * explicitly initialize the Windows function tables here since
+ * DllMain() will not be invoked.
+ */
+
+ TkWinXInit(GetModuleHandle(NULL));
+ #endif
+
/*
* Ensure that we are getting the matching version of Tcl. This is
* really only an issue when Tk is loaded dynamically.
*** win/tkWin32Dll.c.origFri Apr 16 03:51:48 1999
--- win/tkWin32Dll.cSat Sep 25 19:33:35 1999
***************
*** 13,26 ****
#include "tkWinInt.h"
! static int tkPlatformId;
- /*
- * The following declaration is for the VC++ DLL entry point.
- */
-
- BOOL APIENTRYDllMain _ANSI_ARGS_((HINSTANCE hInst,
- DWORD reason, LPVOID reserved));
/*
*----------------------------------------------------------------------
--- 13,22 ----
#include "tkWinInt.h"
! #if defined(_MSC_VER) || defined(__GNUC__)
! #define DllEntryPoint DllMain
! #endif
/*
*----------------------------------------------------------------------
***************
*** 32,63 ****
*routine.
*
* Results:
! *See DllMain.
! *
! * Side effects:
! *See DllMain.
! *
! *----------------------------------------------------------------------
! */
!
! BOOL APIENTRY
! DllEntryPoint(hInst, reason, reserved)
! HINSTANCE hInst;/* Library instance handle. */
! DWORD reason;/* Reason this function is being called. */
! LPVOID reserved;/* Not used. */
! {
! return DllMain(hInst, reason, reserved);
! }
!
! /*
! *----------------------------------------------------------------------
! *
! * DllMain --
! *
! *DLL entry point.
! *
! * Results:
! *TRUE on sucess, FALSE on failure.
*
* Side effects:
*None.
--- 28,34 ----
*routine.
*
* Results:
! *TRUE on success, FALSE otherwise.
*
* Side effects:
*None.
***************
*** 66,77 ****
*/
BOOL APIENTRY
! DllMain(hInstance, reason, reserved)
! HINSTANCE hInstance;
! DWORD reason;
! LPVOID reserved;
{
- OSVERSIONINFO os;
/*
* If we are attaching to the DLL from a new process, tell Tk about
--- 37,47 ----
*/
BOOL APIENTRY
! DllEntryPoint (
! HINSTANCE hInstance,/* Library instance handle. */
! DWORD reason,/* Reason this function is being called. */
! LPVOID reserved)/* Not used. */
{
/*
* If we are attaching to the DLL from a new process, tell Tk about
***************
*** 80,119 ****
*/
if (reason == DLL_PROCESS_ATTACH) {
- os.dwOSVersionInfoSize = sizeof(os);
- GetVersionEx(&os);
- tkPlatformId = os.dwPlatformId;
-
TkWinXInit(hInstance);
} else if (reason == DLL_PROCESS_DETACH) {
TkWinXCleanup(hInstance);
}
return(TRUE);
}
-
- /*
- *----------------------------------------------------------------------
- *
- * TkWinGetPlatformId --
- *
- *Determines whether running under NT, 95, or Win32s, to allow
- *runtime conditional code.
- *
- * Results:
- *The return value is one of:
- * VER_PLATFORM_WIN32sWin32s on Windows 3.1.
- * VER_PLATFORM_WIN32_WINDOWSWin32 on Windows 95.
- * VER_PLATFORM_WIN32_NTWin32 on Windows NT
- *
- * Side effects:
- *None.
- *
- *----------------------------------------------------------------------
- */
-
- int
- TkWinGetPlatformId()
- {
- return tkPlatformId;
- }
-
--- 50,58 ----
*** win/tkWinX.c.origFri Jul 9 04:10:07 1999
--- win/tkWinX.cSat Sep 25 19:33:35 1999
***************
*** 26,31 ****
--- 26,32 ----
*/
int tkpIsWin32s = -1;
+ static int tkPlatformId;
/*
* Declarations of static variables used in this file.
***************
*** 142,148 ****
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&info);
! tkpIsWin32s = (info.dwPlatformId == VER_PLATFORM_WIN32s);
if (childClassInitialized != 0) {
return;
--- 143,150 ----
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&info);
! tkPlatformId = info.dwPlatformId;
! tkpIsWin32s = (tkPlatformId == VER_PLATFORM_WIN32s);
if (childClassInitialized != 0) {
return;
***************
*** 1132,1132 ****
--- 1134,1161 ----
}
+
+ /*
+ *----------------------------------------------------------------------
+ *
+ * TkWinGetPlatformId --
+ *
+ *Determines whether running under NT, 95, or Win32s, to allow
+ *runtime conditional code.
+ *
+ * Results:
+ *The return value is one of:
+ * VER_PLATFORM_WIN32sWin32s on Windows 3.1.
+ * VER_PLATFORM_WIN32_WINDOWSWin32 on Windows 95.
+ * VER_PLATFORM_WIN32_NTWin32 on Windows NT
+ *
+ * Side effects:
+ *None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ int
+ TkWinGetPlatformId()
+ {
+ return tkPlatformId;
+ }
+
PatchFiles:
tkWindow.c tkWin32Dll.c tkWinX.c
|