digitalmars.D.learn - 32/64 bit in Phobos
- Jason den Dulk (9/9) Mar 07 2015 Hi
- Rikki Cattermole (13/21) Mar 07 2015 They are not explicitly uint/ulong ext.
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
Mar 07 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. RegardsThey 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.
Mar 07 2015