Author: Jan Nijtmans <[email protected]> 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
It will not be removed from the Tk headers, just from the documentation.
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 return type:
Tk_Offset() returns an
offsetof() returns 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, so the size of the type matches the size returned
offsetof(). 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.