Author: Jan Nijtmans <email@example.com> State: Draft Type: Project Vote: Pending Created: 05-Dec-2018 Post-History: Tcl-Version: 8.7 Tk-Branch: offsetof
This TIP proposes to deprecate
Tk_Offset() in favour of
Tk_Offset() macro comes from the past, when C's official
macro didn't exist yet, or was not supported yet by all compilers.
The main difference between
is the type:
Tk_Offset() gives an
offsetof() gives a
size_t is actually
more correct, because it cannot become negative and it allows for values >= 4Gb on 64-bit platforms.
This TIP proposes to deprecate the
Tk_Offset() macro. Starting with
Tk 8.7, when compiling an extension with the flag
Tk_Offset() will no longer be provided by tk.h. All occurrences
Tk_Offset() within Tk itself are replaced by
This TIP doesn't propose to remove
Tk_Offset() altogether, since there
are too many extensions still using it.
Further on, it makes sense to change various struct member types from
size_t, to make room for this enhancements. For reasons
of upwards compatibility, providing a smooth upgrade path, when
compiling Tk against Tcl 8.x headers, the type of those struct
members will continue to be
While on it, this TIP proposes to change the
char * to
void *. Although unrelated to
the other proposed changes, this allows various type casts to
be eliminated in the source code of Tk (and possibly in extensions).
Since those fields are used to store untyped pointers, this is
actually a bug-fix which should not need a TIP, but since it affects
the documentation it doesn't hurt to provide this change in a TIP anyway.
An implementation of this TIP can be found in the [offsetof] branch.
This document has been placed in the public domain.