Version 7 of Resize of the mp_digit type

Updated 2009-11-16 19:26:57 by dgp

In Tcl releases 8.5.0 through 8.5.7, the public header file tcl.h contains the typedef:

typedef unsigned long mp_digit;

Starting in Tcl 8.5.8, this is changed to:

typedef unsigned int mp_digit;

The purpose of this page is to discuss what incompatibilities this may introduce for C code that uses the Tcl public interface, and how to manage them.


First, note that on many (32-bit) systems, long and int are just two names for the same thing. If your C code is only ever compiled on such systems, the change is not really a change at all, and you have no compatibility issues to worry about.

For C code that does get compiled for L64 systems, read on...


The set of public Tcl routines that are affected by this change can only be called from a compilation unit that includes the header file tclTomMath.h in addition to tcl.h. For those C source files that do not include the tclTomMath.h header, there can be no incompatibility in how the Tcl public interface is used introduced by this change.

Having eliminated that possibility, the only remaining thing to check is whether you have your own C code that for some reason contains expressions that operate on variables of type mp_digit. If that is the case, you will need to examine what impact this change has for builds on LP64 systems. Since that situation is unlikely, and has nothing to do with calls into Tcl public routines, we'll say no more about it here.