March 08, 2015 32/64 bit in Phobos | ||||
---|---|---|---|---|
| ||||
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 |
March 08, 2015 Re: 32/64 bit in Phobos | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason den Dulk | 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.
|
Copyright © 1999-2021 by the D Language Foundation