Tk Source Code

View Ticket
Login
Ticket UUID: b405da2aad74715fdf8c729fdcfcc0a75d56b64b
Title: Makefile forces -D__USE_MINGW_ANSI_STDIO=0
Type: Support Version: 8.6
Submitter: oscarfv Created on: 2025-10-26 23:06:13
Subsystem: 85. Win Build Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2025-10-27 10:08:48
Resolution: Rejected Closed By: oscarfv
    Closed on: 2025-10-27 10:08:48
Description:
win/Makefile.in contains:

CFLAGS		= @CFLAGS@ @CFLAGS_DEFAULT@ -D__USE_MINGW_ANSI_STDIO=0

Why the -D__USE_MINGW_ANSI_STDIO=0 ?

In MSYS2/Mingw-packages we set -D__USE_MINGW_ANSI_STDIO=1 and in this case tk's makefile is overriding it.

If an application that uses __USE_MINGW_ANSI_STDIO=1 embeds tcl/tk, it *might* cause issues.

Ditto for tcl/win/Makefile.in.
User Comments: oscarfv added on 2025-10-27 10:08:48:
Thank you for the detailed explanation.

A few remarks:

I64 is supported by mingw-w64 for many years now.

On your explanation I think you are mentioning that the tcl/tk build sets __USE_MINGW_ANSI_STDIO=1 when it actually is =0.

MSYS2/Mingw-packages wants to be a complete repository. We even have twapi now :-) Hence, compatibility with VS is a non-goal, although I understand why it is important for you as a policy.

For these reasons we probably end overriding CFLAGS to remove __USE_MINGW_ANSI_STDIO=0 and be consistent with the rest of the MSYS2/Mingw-packages ecosystem. I mention this just in case it is relevant for future exchanges. It would be nice if we had an explicit knob (i.e. a configure option) instead of a blanket override, but for now CFLAGS= would do.

Thank you again.

jan.nijtmans added on 2025-10-27 08:45:50:

Thanks for submitting all those reports! I'm sure that there are issues with MSYS2/Mingw in Tcl, I would like to fix those here. However, this one is done intentionally. I'll explain.

The gcc/clang Tcl build is supposed to be a drop-in replacement for a Visual Studio build of Tcl. That means, whenever there is a incompatibility between gcc/clang and Visual Studio, Visual Studio always wins (no matter whether we like it or not, it might very well be that the gcc/clang implementation is better). Also, binary extensions (e.g. itcl) can be compiled with Visual Studio, this should work fine even though Tcl is compiled with gcc/clang.

So, you are right that "If an application that uses __USE_MINGW_ANSI_STDIO=1 embeds tcl/tk, it *might* cause issues.". The other way around means that if an application is compiled with Visual Studio and uses a Tcl dll built with gcc/clang, this *might* cause issues as well. Since Visual Studio always wins, we have to choose for __USE_MINGW_ANSI_STDIO=1. I'm aware that in a MSYS2/Mingw environment this is not an issue: All Tcl extensions will be built with __USE_MINGW_ANSI_STDIO=1. So I fully agree that you will want to make a different choice.

I'll show a real-life example. Suppose that an extension does something like:

    __int64 value = foo();
    Tcl_Panic("Value: %" TCL_LL_MODIFIER "d", value);

Older Visual Studio versions don't have the "ll" specifier, so in order to be compatible with those versions TCL_LL_MODIFIER resolves to "I64". But the Mingw stdio doesn't recognise "I64" (unless it is recently added ...).

The last reason is: Using __USE_MINGW_ANSI_STDIO=1 together with --static-libgcc brings in a lot of stuff, increasing the Tcl dll size. (this is not the main argument, the main argument is compatibility with Visual Studio)

I hope you understand that therefore I have to reject this ticket :-(