Version 12 of Migration to 8.4: CONSTification

Updated 2002-07-10 19:51:58

As approved in TIP 27 [L1 ], several of the public C functions provided by the Tcl and Tk libraries have had their declarations augmented with the addition of CONST modifiers on pointers. If you have C code, either an application or a package, that makes calls into the Tcl or Tk libraries, you may find that this code that compiled against the public header files (tcl.h and tk.h) of releases 8.3.* of Tcl and Tk will no longer compile against the public header files of releases 8.4*. This page is meant to guide you through making the required changes to your code to restore the ability to compile with the new headers.


Most stuff can be fixed by putting CONST (or, if you're unlucky, CONST84) in your types. Sometimes you might need to add a cast. Anything that traditionally worked, will continue to work. There's also a symbol you can #define to switch off the constness in the interface (whose name I don't remember)

The define is USE_NON_CONST.


Is the new constness adding value? If so, turning it off seems like it would defeat that added value. If the new constness is not adding value, then it would seem like turning it off by default would be as good a solution as having it turned on.

And if the new constness is adding value, then will automatically adding CONST to types cause any other problems?


DGP The answers are subtler than the sketch above implies. I will get to this. Please be patient.

For example USE_NON_CONST does not disable all the TIP 27 changes. It is a more careful, more useful migration tool than that.


See also Changes in Tcl/Tk 8.4