32/64 bit in Phobos
Rikki Cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Mar 7 17:59:40 PST 2015
On 8/03/2015 2:49 p.m., Jason den Dulk wrote:
> Hi
>
> I noticed that in 32bit, many Phobos functions use int and uint, while
> in 64bit, they use long and ulong. As a result I am having some
> difficulty in writing code that works for both 32 bit and 64 bit. Is
> there an existing mechanism that allows writing code that will work in
> both 32 bit and 64 bit with regards to function calls to Phobos?
>
> Thanks.
> Regards
They are not explicitly uint/ulong ext.
They use size_t and ptrdiff_t.
Basically the definition is:
version(X86_64) {
alias size_t = ulong;
alias ptrdiff_t = long;
} else version(X86) {
alias size_t = uint;
alias ptrdiff_t = long;
}
uint conversion to ulong is fine.
ulong to uint isn't. So if you really really want to use uint's. Just cast.
More information about the Digitalmars-d-learn
mailing list