• architecture type?

    From saito@saitology9@gmail.com to comp.lang.tcl on Mon Sep 14 09:49:46 2026
    From Newsgroup: comp.lang.tcl

    Is there a cross platform way to tell if a tcl build is a 32-bit or 64-bit?

    tcl_platform(wordsize) doesn't seem to be reliable as it reports 4 in
    both cases. tcl_platform(pointerSize) reports 4 and 8 for 32-/64-bits, respectively. Is this the way to go?

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Olivier@user1108@newsgrouper.org.invalid to comp.lang.tcl on Mon Sep 14 15:41:35 2026
    From Newsgroup: comp.lang.tcl


    saito <saitology9@gmail.com> posted:

    Is there a cross platform way to tell if a tcl build is a 32-bit or 64-bit?

    tcl_platform(wordsize) doesn't seem to be reliable as it reports 4 in
    both cases. tcl_platform(pointerSize) reports 4 and 8 for 32-/64-bits, respectively. Is this the way to go?


    It has worked for me for Windows 7 32bit and Windows 10 and 11 64bit . Catching
    an error when loading a 32bit extension could be more accurate and
    it works for any OS ?

    Olivier.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Mon Sep 14 18:09:50 2026
    From Newsgroup: comp.lang.tcl

    Am 14.09.2026 um 15:49 schrieb saito:
    Is there a cross platform way to tell if a tcl build is a 32-bit or 64-bit?

    tcl_platform(wordsize) doesn't seem to be reliable as it reports 4 in
    both cases. tcl_platform(pointerSize) reports 4 and 8 for 32-/64-bits, respectively. Is this the way to go?


    Yes, pointerSize is the way, at least on MS-Win.
    And what about:

    package require platform
    platform::generic

    There is no "_64" suffix when compiled for 32 bit on a 64 bit platform.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Mon Sep 14 18:10:35 2026
    From Newsgroup: comp.lang.tcl

    * saito <saitology9@gmail.com>
    | tcl_platform(wordsize) doesn't seem to be reliable as it reports 4 in
    | both cases.

    https://www.tcl-lang.org/man/tcl/TclCmd/tclvars.html

    tcl_platform(wordsize) is documented as the result of sizeof(long),
    which is 4 only on Windows for both 32 and 64 bits.
    On 64-bit Linux, tcl_platform(wordsize) is 8:

    $ tclsh
    % parray tcl_platform
    tcl_platform(machine) = x86_64
    tcl_platform(os) = Linux
    tcl_platform(osVersion) = 6.12.107+deb13-amd64
    tcl_platform(platform) = unix
    tcl_platform(pointerSize) = 8
    tcl_platform(wordSize) = 8
    [...]

    | tcl_platform(pointerSize) reports 4 and 8 for 32-/64-bits,
    | respectively.

    tcl_platform(pointerSize) is the result of sizeof(void*) (aka pointer
    size), which is the closest you get (most likely '4' for 32-bit OSes and
    '8' for 64-bit OSes).

    The question would be why it matters to your code?

    R'
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From saito@saitology9@gmail.com to comp.lang.tcl on Mon Sep 14 16:09:35 2026
    From Newsgroup: comp.lang.tcl

    On 9/14/2026 9:49 AM, saito wrote:
    Is there a cross platform way to tell if a tcl build is a 32-bit or 64-bit?

    tcl_platform(wordsize) doesn't seem to be reliable as it reports 4 in
    both cases. tcl_platform(pointerSize) reports 4 and 8 for 32-/64-bits, respectively. Is this the way to go?


    Thanks to all for the replies. So the consensus is to use the
    pointerSize attribute.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Christian Gollwitzer@auriocus@gmx.de to comp.lang.tcl on Mon Sep 14 22:46:20 2026
    From Newsgroup: comp.lang.tcl

    Am 14.09.26 um 22:09 schrieb saito:
    On 9/14/2026 9:49 AM, saito wrote:
    Is there a cross platform way to tell if a tcl build is a 32-bit or
    64-bit?

    tcl_platform(wordsize) doesn't seem to be reliable as it reports 4 in
    both cases. tcl_platform(pointerSize) reports 4 and 8 for 32-/64-bits,
    respectively. Is this the way to go?


    Thanks to all for the replies. So the consensus is to use the
    pointerSize attribute.

    Use whatever you need. That's also my question, what do you need this information for?

    pointerSize gives you the size of the adressable memory. wordSize gives
    you the size of a long. Those are not necessarily the same - on Win64
    bit, long is 32 bit and void* 64 bit, whereas on Linux, both are 64 bit.
    When you write all of your code in Tcl, wordSize does not matter much,
    because it has bigInts. For interfacing with C subroutines that use Tcl_GetLongFromObj(), those will accept different ranges. Usually, you
    should not need either of them (in a perfect world).

    Christian
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From saito@saitology9@gmail.com to comp.lang.tcl on Mon Sep 14 20:40:14 2026
    From Newsgroup: comp.lang.tcl

    On 9/14/2026 4:46 PM, Christian Gollwitzer wrote:
    Am 14.09.26 um 22:09 schrieb saito:
    On 9/14/2026 9:49 AM, saito wrote:
    Is there a cross platform way to tell if a tcl build is a 32-bit or
    64-bit?

    tcl_platform(wordsize) doesn't seem to be reliable as it reports 4 in
    both cases. tcl_platform(pointerSize) reports 4 and 8 for 32-/64-
    bits, respectively. Is this the way to go?


    Thanks to all for the replies. So the consensus is to use the
    pointerSize attribute.

    Use whatever you need.

    Well, "whatever" doesn't work. For example, wordSize returns the same
    number for me on both 32-bit and 64 bit on the same PC.


    That's also my question, what do you need this
    information for?


    More of an idle curiosity over tcl_platform than anything else at this
    point, though there are instances when that could be useful. Python has
    an explicit function for this called sys.maxsize. If larger than 2**32,
    it is 64 bits.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From saito@saitology9@gmail.com to comp.lang.tcl on Mon Sep 14 20:42:43 2026
    From Newsgroup: comp.lang.tcl

    On 9/14/2026 12:10 PM, Ralf Fassel wrote:

    https://www.tcl-lang.org/man/tcl/TclCmd/tclvars.html


    Thanks for this link.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Tue Sep 15 10:11:17 2026
    From Newsgroup: comp.lang.tcl

    * saito <saitology9@gmail.com>
    | Python has an explicit function for this called sys.maxsize. If larger
    | than 2**32, it is 64 bits.

    I think all you can deduce from "> 2**32" is that it's larger than 32
    bits (eg could be 128 bits). It is the same problem as in "if it is
    larger than 32768, it's 32 bits". That was probably mostly true some
    decades ago when the change from 16 to 32 bits was made, but no longer
    today.

    I would go with Haralds' suggestion and check for the trailing "*64" in [platform::generic].

    https://www.tcl-lang.org/man/tcl/TclCmd/platform.html

    DESCRIPTION
    The platform package provides several utility commands useful for the
    identification of the architecture of a machine running Tcl.


    Keep in mind that even on a 64-bit OS, a 32-bit build of TCL still has "pointersize 4" and "*ix86" in platform::generic.

    R'
    --- Synchronet 3.22a-Linux NewsLink 1.2