Skip to content
Tcl Source Code Changes To Migrating C extensions to Tcl 9
Login

Changes To Migrating C extensions to Tcl 9

Changes to "Migrating C extensions to Tcl 9" between 2024-04-14 11:28:50 and 2024-04-23 06:38:42

︙
216
217
218
219
220
221
222
223
224


225
226
227
228

229






230

231
232
233
234
235
236
237
216
217
218
219
220
221
222


223
224
225
226
227

228
229
230
231
232
233
234
235

236
237
238
239
240
241
242
243







-
-
+
+



-
+

+
+
+
+
+
+
-
+







be directly accessed without a function call for each element.

## Tommath

Tcl 9 optionally allows the linking of an external `libtommath` library for multiple-precision
integer arithmetic in lieu of Tcl's internal version. This has some consequences for extensions:

* If including `tclTomMath.h`, Tcl's stubs interface to `libtommath` is used and only a subset of
`libtommath` functions are available. If including `tommath.h` (external library), all `libtommath`
* (Method 1) If including `tclTomMath.h`, Tcl's stubs interface to `libtommath` is used and only a subset of
`libtommath` functions are available. (Method 2) If including `tommath.h` (external library), all `libtommath`
functions are available.

* Extensions using the definitions of `mp_digit`, `mp_word` or `mp_int` need to include either
 `tclTomMath.h` or `tommath.h` in addition `tcl.h`.
 `tclTomMath.h` or `tommath.h` in addition to `tcl.h`.

The extension needs to call `Tcl_TomMath_InitStubs` if it included `<tclTomMath.h>` (Method 1).
It doesn't need to call `Tcl_TomMath_InitStubs` if it includes `<tommath.h>`
(Method 2, but then it has to link with the libtommath library itself, `-ltommath`).
The extension can freely choose what it wants. However, the disadvantage of Method 2 
is that the extension loses 8.6-compatibility.

See See [TIP 538](https://core.tcl-lang.org/tips/doc/trunk/tip/538.md).
See [TIP 538](https://core.tcl-lang.org/tips/doc/trunk/tip/538.md).

## Building

### Building with autotools

* Update TEA to the latest [tclconfig](https://core.tcl-lang.org/tclconfig).

︙