Author: Jan Nijtmans <[email protected]> State: Final Type: Project Vote: Done Created: 13-Dec-2019 Post-History: Keywords: Tcl Tcl-Version: 8.7 Tcl-Branch: cplusplus Vote-Summary: Accepted 2/0/3 Votes-For: JN, KW Votes-Against: none Votes-Present: DGP, FV, SL
Every once in a while there is a request to be able to compile Tcl with a C++ compiler. This would - in theory - allow C++ exceptions thrown by extensions to be handled by Tcl. This TIP is NOT about adding any code to Tcl doing that. But - as a first step - at least, Tcl needs to compile well with a C++ compiler even though we don't use any C++ features.
This TIP proposes making Tcl compilable with a C++ compiler, without actually using any C++ features.
The Tcl source-code has been strictified in the following ways:
No C++ keywords are allowed any more, such as
class, for variable names.
No automatic casts from
(void *)to other types any more, so all malloc's must be preceded by a type casts. And a
clientDatavariable cannot be assigned directly any more to a variable of another type. This situation requires a type cast from now on in the Tcl core.
All core C-code now compiles warning-free when using the (gcc) options
-Wall -Wextra -Wwrite-strings -Wpointer-arith.
Travis build sections are added, which compile Tcl with g++ (UNIX/Windows). So, any future commit which violates C++ compilation will lead to a failed build.
Nothing is done yet in the Tcl code to handle C++ exception, neither is any of the API now available as C++ classes.
Tk has a
cplusplus branch as well, doing the same. This work is complete for
UNIX, but not yet for Windows and MacOS.
C++ is more strict in using enum's than C is. Enums cannot be stored in
ints (and reverse) without type casts in C++. Tcl doesn't use enums, but there
was one external API function (in ttk) which actually used enum but
its argument in the public API was int:
This TIP deprecates
Ttk_GetOrientFromObj, and adds a new internal
TtkGetOrientFromObj with the correct signature. I didn't
find any extension using
This document has been placed in the public domain.