platform(n)
π platform(n) π
okay bestie, pull up a chair β this is the platform page from Tcl Bundled Packages, aka the little toolkit that tells you exactly what kind of machine your Tcl code is vibing on. π¦
β¨ NAME β¨
platform β System identification support code and utilities π
πΈ SYNOPSIS πΈ
package require platform ?1.0.10?
platform::generic
platform::identify
platform::patterns identifier
π DESCRIPTION π
The platform package hands you a couple of utility commands that are lowkey essential for figuring out the architecture of the machine your Tcl is running on. main character energy for sysadmin girlies. β¨
So here's the tea π: Tcl does give you the tcl_platform array for identifying the current architecture β specifically the platform and machine elements β but bestie, that is not always enough. Why? Because on Unix machines, tcl_platform just reflects whatever values the uname command spat back, and those are not standardized across platforms and architectures. Not even a little. π
And it gets worse: on at least one platform (AIX), tcl_platform(machine) contains the CPU serial number. Like... what. π
So what happens? Individual applications end up having to massage the values in tcl_platform (plus the output of whatever system-specific utilities exist) all by themselves. That's inconvenient for developers, and it opens the door to inconsistencies in identifying architectures and in naming conventions. Messy. π
The platform package exists to stop that fragmentation, periodt. It sets up a standard naming convention for architectures running Tcl and makes it way more convenient for developers to identify the current architecture a Tcl program is running on. iconic behavior, honestly. π
β COMMANDS β
platform::identifyβ This command returns an identifier describing the platform the Tcl core is running on. The returned identifier has the general formatOS-CPU. TheOSpart of the identifier may contain details like kernel version, libc version, etc., and this information may contain dashes as well. TheCPUpart will not contain dashes, making the preceding dash the last dash in the result. π§platform::genericβ This command returns a simplified identifier describing the platform the Tcl core is running on. In contrast toplatform::identify, it leaves out details like kernel version, libc version, etc. The returned identifier has the general formatOS-CPU. π¦platform::patternsidentifier β This command takes an identifier as returned byplatform::identifyand returns a list of identifiers describing compatible architectures. π
π EXAMPLE π
This can be used to allow an application to be shipped with multiple builds of a shared library, so that the same package works on many versions of an operating system. For example:
package require platform
# Assume that app script is .../theapp/bin/theapp.tcl
set binDir [file dirname [file normalize [info script]]]
set libDir [file join $binDir .. lib]
set platLibDir [file join $libDir [platform::identify]]
load [file join $platLibDir support[info sharedlibextension]]
one package, many OS versions, zero drama. π
π₯ KEYWORDS π₯
operating system, cpu architecture, platform, architecture
and that's the whole page, bestie β no cap. π«Ά This one's platform, version 1.0.4, from the Tcl Bundled Packages manual collection. Go identify some architectures. Slay. π β¨
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 2006 ActiveState Software Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms