digitalmars.D.learn - Why .length on Windows is int and on Linux is ulong?
- Suliman (6/6) Feb 29 2016 On Windows next code work fine:
- Rikki Cattermole (3/9) Feb 29 2016 Its not OS dependent, its arch dependent.
- ag0aep6g (8/14) Feb 29 2016 On Windows, the compiler flag -m32 is the default, regardless of dmd's
On Windows next code work fine: int len = fullimgurl.length; On Linux DMD get error that: Error: cannot implicitly convert expression (fullimgurl.length) of type ulong to int Why on every OS length have different size?
Feb 29 2016
On 01/03/16 12:06 AM, Suliman wrote:On Windows next code work fine: int len = fullimgurl.length; On Linux DMD get error that: Error: cannot implicitly convert expression (fullimgurl.length) of type ulong to int Why on every OS length have different size?Its not OS dependent, its arch dependent. On Windows you are building in 32bit mode but on Linux 64bit.
Feb 29 2016
On 29.02.2016 12:06, Suliman wrote:On Windows next code work fine: int len = fullimgurl.length; On Linux DMD get error that: Error: cannot implicitly convert expression (fullimgurl.length) of type ulong to int Why on every OS length have different size?On Windows, the compiler flag -m32 is the default, regardless of dmd's bitness [1]; on Linux it's -m64 for 64 bit dmd [2]. That's what causes the different sizes. Use size_t for lengths, not int or ulong or any other specifically sized type. By the way, with -m32, size_t is uint, not int. [1] http://dlang.org/dmd-windows.html#switch-m32 [2] http://dlang.org/dmd-linux.html#switch-m64
Feb 29 2016