Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Doc fix in tcl.h

Closed / Fixeda73c79081e8eab681b3d940e57ccd9e3abf5e86fCreated 6 years agoUpdated 6 years ago
Descriptionplain2021-04-09 23:05:12
Index: generic/tcl.h
==================================================================
--- generic/tcl.h
+++ generic/tcl.h
@@ -2134,12 +2134,14 @@
  */
 
 #if TCL_UTF_MAX > 3
     /*
      * int isn't 100% accurate as it should be a strict 4-byte value
-     * (perhaps wchar_t). ILP64/SILP64 systems may have troubles. The
-     * size of this value must be reflected correctly in regcustom.h.
+     * (perhaps wchar_t, but certainly not on Windows since they have
+     * 16 bit wchar_t equivalent to WCHAR). ILP64/SILP64 systems may
+     * have troubles. The size of this value must be
+     * reflected correctly in regcustom.h.
      */
 typedef int Tcl_UniChar;
 #else
 typedef unsigned short Tcl_UniChar;
 #endif
Referenced by3
  • ef3c9a8997Fix [a73c79081e]: Doc fix in tcl.h. Recommend int32_t in stead of wchar_t check-in2021-05-26 11:23:19
  • 8c52ca3059Fix [a73c79081e]: Doc fix in tcl.h, by not suggesting wchar_t any more for Tcl_UniChar. check-in2021-05-26 10:47:20
  • af368a8f46Fix [a73c79081e]: Doc fix in tcl.h, by not suggesting wchar_t any more for Tcl_UniChar. check-in2021-05-26 10:45:17
jan.nijtmanswiki2021-05-26 12:40:30

Fixed in all branches.

wchar_t is a bad idea on all platforms, not only windows. int32_t would be better, but it is not available always.

Thanks!

chwplain2021-05-26 16:57:19
For the record: I'm not happy with the elimination of wording regarding
wchar_t since it is IMHO *important* information for future implementors
and porters (without capitalization, howdy DGP!) of still to be defined
and invented platforms. Certainly, my initial proposal had the possibilty
to be understood somewhat sarcastically. My fault!

Don't forget, the future is unwritten. And here's a better wording:

On current POSIX platforms, wchar_t is a candidate, as long as it can be
assured, that wchar_t is a 32 bit quantity. On Windows, a wchar_t is
equivalent to the WCHAR data type, which is only 16 bits wide and thus
definitely not useable here. If the compiler and target platform have an
int32_t data type, this might be the best choice. Maybe this should be
made a configure time option, but this needs to be layed out in a TIP.
jan.nijtmanswiki2021-05-27 08:56:42

Understood. However, for Tcl 8.5 and 8.6, TCL_UTF_MAX>3 is not supported, to there's no use to give any advise. For Tcl 8.7 and 9.0, we have TIP #592, which - basically - means we have int32_t. Problem: Changing this would mean that tcl.h would start depending on <stdint.h>, I'm not sure we want that.

I don't know any platform where int != 32 bits, so the current implementation works fine now. As soon as someone actually wants to use Tcl (9.0) in such an environment, we can have a look at this again. But for now I don't see any urge to change it.

Did you see the comment in tcl.h is different for Tcl 8.5/8.6 compared to Tcl 8.7/9.0?

chwplain2021-05-27 19:34:09
Despite TCL_UTF_MAX>3 being not supported on Tcl <= 8.6, the importance
of tcl.h is IMO stronger than TIPpery, since it specifies the real interface
for the respective version. Thus, it is not a bad idea to have some clear 
explanation in the comment to Tcl_UniChar.
Log in (anonymous is fine) to add a comment.