Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Compilation error of C extensions due to TCL_SIZE_MAX definition

Closed / Fixed64165953a0b4778074a9bd14b6ad55f550b606e9Created 3 years agoUpdated 3 years ago
Descriptionplain2023-08-26 15:29:17
In Tcl 8.7 and 9.0 the following macro is defined in tcl.h:
#define TCL_SIZE_MAX PTRDIFF_MAX

The macro PTRDIFF_MAX is defined in header file stdint.h, 
but this header file is not included in tcl.h.

I would suggest to add the following line to tcl.h:
#include <stdint.h>
Referenced by1
  • f9875fd78bFix [64165953a0]: Compilation error of C extensions due to TCL_SIZE_MAX definition check-in2023-08-27 16:46:10
jan.nijtmansplain2023-08-27 16:55:34
Fixed [here|f9875fd78bf62318]

Since INT_MAX is defined by <limits.h> and PTRDIFF_T by <stdint.h>, it would mean that the set of header files included by <tcl.h> would be different in Tcl 8.7 and 9.0. That's why it's better - just for this single usage - to #define TCL_SIZE_MAX without using INT_MAX/PTRDIFF_MAX.

Thanks for your report!
anonymousplain2023-08-27 19:21:34
Hi Jan,

unfortunately your change breaks the Tcl9 build.
In file tclInt.h (function TclGetSizeIntFromObj) the line
#if TCL_SIZE_MAX == INT_MAX
cannot be resolved by the pre-processor anymore with the new TCL_SIZE_MAX definition.

Paul
jan.nijtmanswiki2023-08-27 20:27:43
apnadkarnimarkdown2023-08-28 03:09:09

Not that I understand why the set of header files needs to be the same between 8.7 and 9.0, but if that is the case the right fix would have been to include stdint.h in 8.7 as well. Particularly when we are talking about C99 standard headers.

There are other types and macros in that header that Tcl should be making use of instead of rolling its own and the move should be towards using standardised headers and types, not the other way.

/Ashok

Log in (anonymous is fine) to add a comment.