Attachment "msvc8.patch" to
ticket [1096916fff]
added by
patthoyts
2005-01-06 09:42:36.
This patch contains a number of changes required to compile Tcl using
Microsoft Visual C++ 8 which is currently provided as part of the
Microsoft Visual Studio 2005 Beta.
To summarize:
regerror.c:
errcode is a typedef declared in the windows headers.
tclWinPort.h:
A large number of C library functions have been marked as depreciated
as part of some secure programming drive at MS. This suppresses the
warnings.
tcl.h:
By default time_t is declared as a 64 bit value. Tcl can't cope with
this so we define _USE_32BIT_TIME_T. This means we must use a
compatible struct version for Tcl_StatBuf
nmakehlp.c:
The error codes have changed.
rules.vc:
makefile.vc:
We need more options checking as a number have been removed.
The result is that Tcl now compiles without warnings. There are 11
test suite failures and one crash. The crash is caused by the C
runtime when we try to convert an illegal time value ( a
legitimate test - blame microsoft). The other failures are due to
some change in the putenv() function which appears to no longer
be changing the environment.
Index: generic/regerror.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/regerror.c,v
retrieving revision 1.3
diff -u -r1.3 regerror.c
--- generic/regerror.c 2 Jun 1999 01:53:30 -0000 1.3
+++ generic/regerror.c 6 Jan 2005 02:27:47 -0000
@@ -50,8 +50,8 @@
*/
/* ARGSUSED */
size_t /* actual space needed (including NUL) */
-regerror(errcode, preg, errbuf, errbuf_size)
-int errcode; /* error code, or REG_ATOI or REG_ITOA */
+regerror(code, preg, errbuf, errbuf_size)
+int code; /* error code, or REG_ATOI or REG_ITOA */
CONST regex_t *preg; /* associated regex_t (unused at present) */
char *errbuf; /* result buffer (unless errbuf_size==0) */
size_t errbuf_size; /* available space in errbuf, can be 0 */
@@ -62,7 +62,7 @@
size_t len;
int icode;
- switch (errcode) {
+ switch (code) {
case REG_ATOI: /* convert name to number */
for (r = rerrs; r->code >= 0; r++)
if (strcmp(r->name, errbuf) == 0)
@@ -84,12 +84,12 @@
break;
default: /* a real, normal error code */
for (r = rerrs; r->code >= 0; r++)
- if (r->code == errcode)
+ if (r->code == code)
break;
if (r->code >= 0)
msg = r->explain;
else { /* unknown; say so */
- sprintf(convbuf, unk, errcode);
+ sprintf(convbuf, unk, code);
msg = convbuf;
}
break;
Index: generic/tcl.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
retrieving revision 1.193
diff -u -r1.193 tcl.h
--- generic/tcl.h 13 Dec 2004 22:17:33 -0000 1.193
+++ generic/tcl.h 6 Jan 2005 02:27:49 -0000
@@ -358,7 +358,11 @@
# define TCL_LL_MODIFIER "L"
# define TCL_LL_MODIFIER_SIZE 1
# else /* __BORLANDC__ */
+# if _MSC_VER < 1400
typedef struct _stati64 Tcl_StatBuf;
+# else
+typedef struct _stat32i64 Tcl_StatBuf;
+# endif /* _MSC_VER < 1400 */
# define TCL_LL_MODIFIER "I64"
# define TCL_LL_MODIFIER_SIZE 3
# endif /* __BORLANDC__ */
Index: win/makefile.vc
===================================================================
RCS file: /cvsroot/tcl/tcl/win/makefile.vc,v
retrieving revision 1.135
diff -u -r1.135 makefile.vc
--- win/makefile.vc 27 Oct 2004 20:53:38 -0000 1.135
+++ win/makefile.vc 6 Jan 2005 02:27:51 -0000
@@ -15,7 +15,7 @@
# RCS: @(#) $Id: makefile.vc,v 1.135 2004/10/27 20:53:38 davygrvy Exp $
#------------------------------------------------------------------------------
-!if !defined(MSDEVDIR) && !defined(MSVCDIR)
+!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR)
MSG = ^
You'll need to run vcvars32.bat from Developer Studio, first, to setup^
the environment. Jump to this line to read the new instructions.
@@ -346,10 +346,16 @@
# Compile flags
#---------------------------------------------------------------------
+# MSVC 2005 changes:
+# -Op gone, use /fp:precise ?
+# /QI0f has been removed.
+# /YX removed - use /Yc or /Yu or better nothing.
+# /GS and /GR are on by default
+
!if !$(DEBUG)
!if $(OPTIMIZING)
### This cranks the optimization level to maximize speed
-cdebug = -O2 -Op -Gs
+cdebug = -O2 $(OPTIMIZATIONS)
!else
cdebug =
!endif
@@ -357,11 +363,11 @@
### Warnings are too many, can't support warnings into errors.
cdebug = -Z7 -Od -GZ
!else
-cdebug = -Z7 -WX -Od -GZ
+cdebug = -Z7 -Od -GZ
!endif
### Declarations common to all compiler options
-cflags = -nologo -c -YX -Fp$(TMP_DIR)^\
+cflags = -nologo -c -Fp$(TMP_DIR)^\
!if $(FULLWARNINGS)
cflags = $(cflags) -W4
@@ -396,7 +402,7 @@
BASE_CFLAGS = $(cflags) $(cdebug) $(crt) $(TCL_INCLUDES) \
-DTCL_PIPE_DLL=\"$(TCLPIPEDLLNAME)\"
CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE
-TCL_CFLAGS = $(BASE_CFLAGS) $(OPTDEFINES)
+TCL_CFLAGS = $(BASE_CFLAGS) $(OPTDEFINES) -D_USE_32BIT_TIME_T
STUB_CFLAGS = $(cflags) $(cdebug) $(OPTDEFINES)
Index: win/nmakehlp.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/nmakehlp.c,v
retrieving revision 1.7
diff -u -r1.7 nmakehlp.c
--- win/nmakehlp.c 10 Feb 2004 22:04:04 -0000 1.7
+++ win/nmakehlp.c 6 Jan 2005 02:27:51 -0000
@@ -192,8 +192,13 @@
CloseHandle(pipeThreads[0]);
CloseHandle(pipeThreads[1]);
- /* look for the commandline warning code in both streams. */
- return !(strstr(Out.buffer, "D4002") != NULL || strstr(Err.buffer, "D4002") != NULL);
+ /* look for the commandline warning code in both streams.
+ * - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002.
+ */
+ return !(strstr(Out.buffer, "D4002") != NULL
+ || strstr(Err.buffer, "D4002") != NULL
+ || strstr(Out.buffer, "D9002") != NULL
+ || strstr(Err.buffer, "D9002") != NULL);
}
int
Index: win/rules.vc
===================================================================
RCS file: /cvsroot/tcl/tcl/win/rules.vc,v
retrieving revision 1.19
diff -u -r1.19 rules.vc
--- win/rules.vc 24 Jun 2004 01:29:07 -0000 1.19
+++ win/rules.vc 6 Jan 2005 02:27:51 -0000
@@ -64,7 +64,7 @@
#----------------------------------------------------------
!if !exist(nmakehlp.exe)
-!if [$(cc32) -nologo -ML nmakehlp.c -link -subsystem:console > nul]
+!if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul]
!endif
!endif
@@ -73,7 +73,7 @@
#----------------------------------------------------------
### test for optimizations
-!if [nmakehlp -c -Otip]
+!if [nmakehlp -c -Oti]
!message *** Compiler has 'Optimizations'
OPTIMIZING = 1
!else
@@ -81,6 +81,24 @@
OPTIMIZING = 0
!endif
+OPTIMIZATIONS =
+
+!if [nmakehlp -c -Op]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -Op
+!endif
+
+!if [nmakehlp -c -fp:strict]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict
+!endif
+
+!if [nmakehlp -c -Gs]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs
+!endif
+
+!if [nmakehlp -c -GS]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -GS
+!endif
+
!if "$(MACHINE)" == "IX86"
### test for pentium errata
!if [nmakehlp -c -QI0f]
Index: win/tclWinPort.h
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinPort.h,v
retrieving revision 1.43
diff -u -r1.43 tclWinPort.h
--- win/tclWinPort.h 3 Nov 2004 21:07:01 -0000 1.43
+++ win/tclWinPort.h 6 Jan 2005 02:27:52 -0000
@@ -406,6 +406,17 @@
# endif
#endif
+
+/*
+ * MSVC 8.0 started to mark many standard C library functions depreciated
+ * including the *printf family and others. Tell it to shut up.
+ * (_MSC_VER is 1200 for VC6, 1300 or 1310 for vc7.net, 1400 for 8.0)
+ */
+#if _MSC_VER >= 1400
+#pragma warning(disable:4996)
+#endif
+
+
/*
* There is no platform-specific panic routine for Windows in the Tcl internals.
*/