Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-01-21
15:36 • Closed ticket [3474726fff]: minGW Tcl_StatBuf not defined correctly in tcl.h... artifact: fb3fe3209f user: nijtmans
2012-01-19
19:54 • Open ticket [3474726fff]. artifact: b3b8f3bab5 user: nijtmans
2012-01-18
22:35 • Ticket [3474726fff]: 4 changes artifact: b1f1adf8e9 user: nijtmans
22:35 • Ticket [3474726fff]: 4 changes artifact: a66957907f user: nijtmans
22:33 • Ticket [3474726fff]: 4 changes artifact: e70a0d0a7a user: nijtmans
22:33 • Add attachment freewrap.patch to ticket [3474726fff] artifact: a4ca6bc845 user: nijtmans
15:15 • Closed ticket [3474726fff]: minGW Tcl_StatBuf not defined correctly in tcl.h... artifact: f3da62b2f8 user: nijtmans
2012-01-17
06:36 • New ticket [3474726fff]. artifact: 424199338c user: jeffrw

minGW Tcl_StatBuf not defined correctly in tcl.h

Closed / Fixed3474726fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2012-01-17 06:36:53
Windows Vista
minGW 5.1.4

configure correctly detects that struct _stat32i64 is not available, and compiles tcl and tk properly, because in the relevant windows code, tclWinPort.h is included with flag HAVE_NO_STRUCT_STAT32I64

But when attempting to compile freewrap, in tcl.h, Tcl_StatBuf is defined to be _stat32i64, and this leads to an error.

I can fix this by including tclWinPort.h and adding a define for HAVE_NO_STRUCT_STAT32I64, but since tclWinPort.h is not a member of the installed include directory, I infer this is not the intended solution.
nijtmansplain2012-01-18 15:15:35
allow_comments - 1

_stat32i64 is supposed to be defined in stat.h, since VS2005, See:
    http://msdn.microsoft.com/en-us/library/14h5k7ff%28v=vs.80%29.aspx
Before that, this structure was named _stati64, but since VS2005
the _stati64 definition became dependent on the _USE_32BIT_TIME_T
macro. We cannot force extensions to set _USE_32BIT_TIME_T,
therefore the workaround to include the _stat32i64 structure
in tclWinPort.h if not available elsewhere.

The real solution is to use a mingw version which has a _stat32i64
definition in sys/stat.h. Another workaround for freewrap could
be to use the fact that if _USE_32BIT_TIME_T is defined
that then _stati64 is the same as _stat32i64. So, freewrap
could use something like (untested!!!):

#define _USE_32BIT_TIME_T
#include <sys/stat.h>
#ifndef _stat32i64
#   define _stat32i64 _stati64
#endif
#include <tcl.h>

See bug 3288345 for more details where this problem come from.
Anyway, it's up to mingw to provide a _stat32i64 definition, or
up to freewrap to provide a workaround when it wants to support
a mingw version which lacks _stat32i64
nijtmansplain2012-01-18 22:33:37
File Added - 433380: freewrap.patch
nijtmansplain2012-01-18 22:35:24
Tried the workaround for freewrap, and it works. See attached "freewrap.patch".

At least generic/zvfs.c compiles on win32 with this change, it should not affect other
platforms.
nijtmansplain2012-01-18 22:35:35
allow_comments - 0
nijtmansplain2012-01-19 19:54:11
Even though this is not Tcl's fault, there is something we can do to
make it easier for extensions  to support older mingw versions.

Proposal: change the tcl.h line:
#         elif (defined(_MSC_VER) && (_MSC_VER < 1400))
to
#         elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T)

Then extension can simply define _USE_32BIT_TIME_T,
which makes Tcl use _stati64, which is available in all
mingw versions. Then the _stat32i64 definition in
tclWinPort.h is only necessary for cygwin, which makes
the detection logic unnecessary. It's much simpler,
both for Tcl and for extensions
nijtmansplain2012-01-21 15:36:26
allow_comments - 1

Done as proposed in all open branches.

Extensions which suffer from a mingw version without
_stat32i64 just have to compile with -D_USE_32BIT_TIME_T,
then everything will be fine. Then Tcl will use _stati64 in
stead of _stat32i64, while keeping full binary
compatibility with VC6.0
Log in (anonymous is fine) to add a comment.

Attachments: