[Python-Dev] warnings compiling tkinter

Martin v. Löwis martin@v.loewis.de
13 Dec 2002 22:14:49 +0100


Jeremy Hylton <jeremy@alum.mit.edu> writes:

> Should I be concerned about these warnings?  Perhaps my version of
> Tcl/Tk is too old?

They are probably const-correctness issues. The functions whose
addresses we are taking now expect const arguments, but didn't before.

Can you try the following patch? If that won't help, please report the
declarations of those functions in your Tcl version.

Regards,
Martin

Index: Modules/_tkinter.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v
retrieving revision 1.137
diff -u -r1.137 _tkinter.c
--- Modules/_tkinter.c	12 Dec 2002 19:05:48 -0000	1.137
+++ Modules/_tkinter.c	13 Dec 2002 21:09:27 -0000
@@ -57,6 +57,12 @@
 #include <tk.h>
 #endif
 
+/* For Tcl 8.2 and 8.3, CONST* is not defined. */
+#ifndef CONST84_RETURN
+#define CONST84_RETURN
+#define CONST
+#endif
+
 #define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
 
 #if TKMAJORMINOR < 8002
@@ -1334,9 +1340,9 @@
 
 TCL_DECLARE_MUTEX(var_mutex)
 
-typedef const char* (*EventFunc1)(Tcl_Interp*, const char*, int);
-typedef const char* (*EventFunc2)(Tcl_Interp*, const char*, const char*, int);
-typedef const char* (*EventFunc3)(Tcl_Interp*, const char*, const char*, const char*, int);
+typedef CONST84_RETURN char* (*EventFunc1)(Tcl_Interp*, CONST char*, int);
+typedef CONST84_RETURN char* (*EventFunc2)(Tcl_Interp*, CONST char*, CONST char*, int);
+typedef CONST84_RETURN char* (*EventFunc3)(Tcl_Interp*, CONST char*, CONST char*, const char*, int);
 typedef struct VarEvent {
 	Tcl_Event ev; /* must be first */
 	TkappObject *self;
@@ -1456,9 +1462,9 @@
 
 static PyObject*
 var_invoke2(PyObject *_self, char* arg1, char* arg2, char* arg3, int flags,
-	   int (*func1)(Tcl_Interp*, const char*, int),
-	   int (*func2)(Tcl_Interp*, const char*, const char*, int),
-	   int (*func3)(Tcl_Interp*, const char*, const char*, const char*, int))
+	   int (*func1)(Tcl_Interp*, CONST char*, int),
+	   int (*func2)(Tcl_Interp*, CONST char*, CONST char*, int),
+	   int (*func3)(Tcl_Interp*, CONST char*, CONST char*, CONST char*, int))
 {
 	return var_invoke(_self, arg1, arg2, arg3, flags,
 			  (EventFunc1)func1, (EventFunc2)func2,