Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl_SetResult compiler warnings

Closed / Fixeddf85199878265b0e5aa4412a569758b5affb66a9Created 3 years agoUpdated 3 years ago
Descriptionwiki2024-04-05 15:14:53
Calls to Tcl_SetResult from Tcl extension packages which previously compiled cleanly in Tcl 8.6.13 are now producing warnings with Tcl 8.6.14.

The extensions are compiled on Windows 10 with Visual Studio 2022, with the /W4 compiler option. The Microsoft docs says /W4 outputs:

all level 4 (informational) warnings that aren't off by default. We recommend that you use this option to provide lint-like warnings.

The extensions are using stubs. Compiler options include: /W4 -DUSE_TCL_STUBS -DUSE_TK_STUBS -DTCL_THREADS=1

With Tcl 8.6.14 any C statement such as:

    Tcl_SetResult( interp, "this is an error message", TCL_STATIC );

now produces a warning:

    warning C4152: nonstandard extension, function/data pointer conversion in expression

The cause appears to be additional macro trickery introduced into tclDecls.h in Tcl 8.6.14:

#if defined(USE_TCL_STUBS)
.......
#ifndef __cplusplus
..........
#   undef Tcl_SetResult
#   define Tcl_SetResult \
	   ((void (*)(Tcl_Interp *, char *, void *))(void *)(tclStubsPtr->tcl_SetResult)) /* 232 */
#endif
#endif

The warning is from the third argument of the Tcl_SetResult macro declaration, which is now void * instead of Tcl_FreeProc *freeProc.

Referenced by2
  • 92e8b69faeClosed ticket [d556d54723]: Inconsistency in Tcl declaration of Tcl_EventuallyFree and Tcl_SetResult causes warnings when compiling. plus 7 other changes ticket2024-07-03 20:19:11
  • 1714783349Fix [df85199878]: Tcl_SetResult compiler warnings check-in2024-04-05 21:25:20
jan.nijtmanswiki2024-04-05 21:21:57

Hm, this piece what meant to prevent another compiler warning, see [8ab8a138c9]. But if it produces another one with MSVC, it's counter-productive. Thanks for the report, indeed it's better to remove this.

Log in (anonymous is fine) to add a comment.