windows64/linux64 Error: cannot implicitly convert expression of type ulong to int

anonymous anonymous at example.com
Mon Feb 18 19:53:15 PST 2013


On Tuesday, 19 February 2013 at 03:33:48 UTC, Anastasios 
Tsiolakidis wrote:
> http://pastebin.ca/2315433 , and compiling it with all 3 
> implementations on my Ubuntu 12.10 gives this "common" eror, in 
> 2 implementations with more verbose output
>
>
> h3.d(72): Error: cannot implicitly convert expression 
> (g0.length) of type ulong to int
>
>
> On Windows 7-64 however it compiles just fine with dmd2.
[...]
> What's going on?


Line 72: int n = g0.length;

Apparently, you're compiling to 32bit on Windows, and to 64bit on 
Ubuntu.
g0.length is of type size_t which is as large as your target 
bitness. int is always 32 bits large. Since you can't cram 64 
bits into 32 bits, the compiler complains when targeting 64bit.

Change that line to this: size_t n = g0.length;


More information about the Digitalmars-d mailing list