[racket] Detecting 32/64-bit racket

From: Thomas Chust (chust at web.de)
Date: Sat Oct 29 10:11:27 EDT 2011

2011/10/29 Norman Gray <norman at astro.gla.ac.uk>:
> [...]
> Is there a recommended way to detect whether racket is a 32- or
> 64-bit executable?
> [...]

Hello Norman,

while I don't know whether this strategy is particularly
recommendable, I would suggest to use utilities from the FFI module:

  (require (only-in ffi/unsafe compiler-sizeof))

  (compiler-sizeof 'long) ; => 8 on a 64-bit system
                          ; => 4 on a 32-bit system

> [...]
> I'm writing a racket extension to wrap a C library
> <http://purl.org/nxg/dist/racket-librdf>, and in the configure.ac, I
> want to be able to detect whether racket is a 32- or 64-bit
> executable, so I know whether to (adjust CFLAGS to) check for a
> suitably-compiled version of the library being wrapped -- a 32-bit
> racket needs a 32-bit underlying library, and so on.
> [...]

While it is true that all the linked objects must be compiled for the
same architecture, this kind of check is automatically performed by
any decent linker without the need for special flags and failure to
find matching libraries will result in a linker error.

You may have to specify flags to the C compiler, though, if the
default target architecture of the compiler doesn't match the
architecture for which Racket and the libraries to be wrapped were
compiled.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


Posted on the users mailing list.