[Haskell-cafe] Defining a type depending on the word size of platform
Diego Souza
dsouza at bitforest.org
Sun Jan 2 15:09:42 CET 2011
Hi,
maybe you have already considered this and dropped it out for whenever
reasons. Anyways, what if you stick with Int or Data.Word.Word types and use
Data.Bits.bitSize or maxBound to check in runtime what the word size is. It
might be easier than using CPP extension.
~dsouza
On Sun, Jan 2, 2011 at 11:16 AM, Daniel Fischer <
daniel.is.fischer at googlemail.com> wrote:
> On Sunday 02 January 2011 13:45:13, Robert Clausecker wrote:
> >
> > I guess the easiest way would be to use CPP, but is there any flag for
> > the wordsize?
>
> Not directly, but I think
>
> {-# LANGUAGE CPP #-}
>
> #include "MachDeps.h"
>
> #if WORD_SIZE_IN_BITS == 32
>
> type MyGen = MyGen32
>
> #else // GHC only works with 32- and 64-bit words
>
> type MyGen = MyGen64
>
> #endif
>
> should do it.
>
> MachDeps.h ties you to GHC of course, if you want it to work on other
> compilers too, I guess you need a configure script.
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
--
~dsouza
yahoo!im: paravinicius
gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B 9ECE F88E 067F E891 651E
gpg pub key: http://bitforest.org/~dsouza/pub/gpg-pubkey.txt
authorized_keys: http://bitforest.org/~dsouza/pub/authorized_keys.txt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110102/4f1ab414/attachment.htm>
More information about the Haskell-Cafe
mailing list