Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Detect 32 vs. 64-bit application

1,265 views
Skip to first unread message

physiologoius

unread,
Mar 17, 2012, 9:30:40 AM3/17/12
to
Following thread has been closed -
http://groups.google.com/group/comp.lang.tcl/browse_frm/thread/4ba1f7818ea7a531/d4dff88e82f43d95?lnk=gst&q=32bit+vs+64bit#d4dff88e82f43d95

I received an advice to try starting a new thread with same subject to
continue discussion.

tcl_platform(wordSize) is a useful way of finding out whether the
executable is 32bit or 64bit. But, as mention Tcl'ers wiki it is not
available across platforms - http://wiki.tcl.tk/1649

I came to know of another solution elsewhere and it seems to work well

set ::tcl_platform(bits) [ expr [ string length [ format %X -1 ] ] *
4 ]

Madhur

Dave

unread,
Mar 17, 2012, 7:01:22 PM3/17/12
to
On 3/17/2012 8:30 AM, physiologoius wrote:
> expr [ string length [ format %X -1 ] ] * 4

Not sure what you intend "bits" to be, but on Win7x64, ActiveTcl
8.5.11.1 64-bit:

% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine) = amd64
tcl_platform(os) = Windows NT
tcl_platform(osVersion) = 6.1
tcl_platform(platform) = windows
tcl_platform(pointerSize) = 8
tcl_platform(threaded) = 1
tcl_platform(user) = imdave
tcl_platform(wordSize) = 4

% expr [ string length [ format %X -1 ] ] * 4
32


tombert

unread,
Mar 19, 2012, 8:55:44 AM3/19/12
to
Use
$tcl_platform(pointerSize)

to determine if you are on 32bit or 64bit.

Donal K. Fellows

unread,
Mar 19, 2012, 10:56:49 AM3/19/12
to
On 17/03/2012 13:30, physiologoius wrote:
> tcl_platform(wordSize) is a useful way of finding out whether the
> executable is 32bit or 64bit. But, as mention Tcl'ers wiki it is not
> available across platforms - http://wiki.tcl.tk/1649

It's more correct to say that it is only present on a sufficiently
modern version of Tcl; tcl_platform(wordSize) was "only" introduced in
Tcl 8.4 after all. But the right thing to do there is to put this at the
start of your script:

package require Tcl 8.4

If that fails, there's no tcl_platform(wordSize) to check. There's also
a machine that's running something that's no longer supported even for
security fixes. Tcl 8.3 (and before) SHOULD NOT BE USED for normal
software deployment. I wouldn't really encourage sticking with just the
8.4 feature set either, to be honest. 8.5 is our full production-grade
release.

Of course, if you _do_ have 8.4 then you have a simple portable word
size check: $tcl_platform(wordSize) :-)

Donal.

Alexandre Ferrieux

unread,
Mar 19, 2012, 1:28:12 PM3/19/12
to
On Mar 19, 3:56 pm, "Donal K. Fellows"
<donal.k.fell...@manchester.ac.uk> wrote:
> On 17/03/2012 13:30, physiologoius wrote:
>
> > tcl_platform(wordSize) is a useful way of finding out whether the
> > executable is 32bit or 64bit. But, as mention Tcl'ers wiki it is not
> > available across platforms -http://wiki.tcl.tk/1649
>
> It's more correct to say that it is only present on a sufficiently
> modern version of Tcl; tcl_platform(wordSize) was "only" introduced in
> Tcl 8.4 after all. But the right thing to do there is to put this at the
> start of your script:
>
>    package require Tcl 8.4
>
> If that fails, there's no tcl_platform(wordSize) to check. There's also
> a machine that's running something that's no longer supported even for
> security fixes. Tcl 8.3 (and before) SHOULD NOT BE USED for normal
> software deployment. I wouldn't really encourage sticking with just the
> 8.4 feature set either, to be honest. 8.5 is our full production-grade
> release.
>
> Of course, if you _do_ have 8.4 then you have a simple portable word
> size check: $tcl_platform(wordSize) :-)

Also, if you are on (a relased) 8.4 *and* 64-bit Linux, you're living
under a Damocles sword, if you ever try to use fileevent with fds
above 32. See https://sourceforge.net/tracker/?func=detail&aid=3486554&group_id=10894&atid=110894

Next 8.4 release, if it comes into existence someday, has the fix
though:

http://core.tcl.tk/tcl/info/7ed1f6f749

-Alex
0 new messages