From 55777cb64df700cc762d127daf47eaf9ec1065e9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 26 Jun 2025 11:14:11 +0000 Subject: Make everthing compile (again) and run with a C++ compiler. --- generic/tclBinary.c | 6 ++---- generic/tclNamesp.c | 10 +++++----- generic/tclTest.c | 6 ++++++ generic/tclThreadTest.c | 6 ++++++ unix/tclAppInit.c | 6 ++++++ win/tclAppInit.c | 6 ++++++ 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 5094a88..1e68415 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2740,13 +2740,13 @@ BinaryEncodeUu( { Tcl_Obj *resultObj; unsigned char *data, *start, *cursor; - int i, bits, index; + int i, bits; unsigned int n; int lineLength = 61; const unsigned char SingleNewline[] = { UCHAR('\n') }; const unsigned char *wrapchar = SingleNewline; Tcl_Size j, rawLength, offset, count = 0, wrapcharlen = sizeof(SingleNewline); - enum { OPT_MAXLEN, OPT_WRAPCHAR }; + enum { OPT_MAXLEN, OPT_WRAPCHAR } index; static const char *const optStrings[] = { "-maxlen", "-wrapchar", NULL }; if (objc < 2 || objc % 2 != 0) { @@ -2805,8 +2805,6 @@ BinaryEncodeUu( return TCL_ERROR; } break; - default: - TCL_UNREACHABLE(); } } diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 5acb014..3670d7f 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -4745,7 +4745,7 @@ NamespaceWhichCmd( static const char *const opts[] = { "-command", "-variable", NULL }; - int lookupType = 0; + enum { OPT_COMMAND, OPT_VARIABLE } lookupType; Tcl_Obj *resultPtr; if (objc < 2 || objc > 3) { @@ -4770,14 +4770,15 @@ NamespaceWhichCmd( TclNewObj(resultPtr); switch (lookupType) { - case 0:; /* -command */ + case OPT_COMMAND: { Tcl_Command cmd = Tcl_GetCommandFromObj(interp, objv[objc-1]); if (cmd != NULL) { Tcl_GetCommandFullName(interp, cmd, resultPtr); } break; - case 1:; /* -variable */ + } + case OPT_VARIABLE: { Tcl_Var var = Tcl_FindNamespaceVar(interp, TclGetString(objv[objc-1]), NULL, /*flags*/ 0); @@ -4785,8 +4786,7 @@ NamespaceWhichCmd( Tcl_GetVariableFullName(interp, var, resultPtr); } break; - default: - TCL_UNREACHABLE(); + } } Tcl_SetObjResult(interp, resultPtr); return TCL_OK; diff --git a/generic/tclTest.c b/generic/tclTest.c index c67ec25..e6c2a94 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -41,8 +41,14 @@ /* * Declare external functions used in Windows tests. */ +#ifdef __cplusplus +extern "C" { +#endif DLLEXPORT int Tcltest_Init(Tcl_Interp *interp); DLLEXPORT int Tcltest_SafeInit(Tcl_Interp *interp); +#ifdef __cplusplus +} +#endif /* * Dynamic string shared by TestdcallCmd and DelCallbackProc; used to collect diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c index 52493c1..faaf92a 100644 --- a/generic/tclThreadTest.c +++ b/generic/tclThreadTest.c @@ -139,7 +139,13 @@ static void ThreadFreeProc(void *clientData); static int ThreadDeleteEvent(Tcl_Event *eventPtr, void *clientData); static void ThreadExitProc(void *clientData); +#ifdef __cplusplus +extern "C" { +#endif extern int Tcltest_Init(Tcl_Interp *interp); +#ifdef __cplusplus +} +#endif /* *---------------------------------------------------------------------- diff --git a/unix/tclAppInit.c b/unix/tclAppInit.c index 6158c99..8d967e8 100644 --- a/unix/tclAppInit.c +++ b/unix/tclAppInit.c @@ -24,8 +24,14 @@ #endif #ifdef TCL_TEST +#ifdef __cplusplus +extern "C" { +#endif extern Tcl_LibraryInitProc Tcltest_Init; extern Tcl_LibraryInitProc Tcltest_SafeInit; +#ifdef __cplusplus +} +#endif #endif /* TCL_TEST */ #ifdef TCL_XT_TEST diff --git a/win/tclAppInit.c b/win/tclAppInit.c index 339d61e..c293952 100644 --- a/win/tclAppInit.c +++ b/win/tclAppInit.c @@ -26,8 +26,14 @@ #endif #ifdef TCL_TEST +#ifdef __cplusplus +extern "C" { +#endif extern Tcl_LibraryInitProc Tcltest_Init; extern Tcl_LibraryInitProc Tcltest_SafeInit; +#ifdef __cplusplus +} +#endif #endif /* TCL_TEST */ #if defined(STATIC_BUILD) -- cgit v0.12