variations of int sizes (and signded/unsigned) between platorms

Jason House jason.james.house at gmail.com
Mon Apr 23 19:30:55 PDT 2007


I have a small section of code that is giving me issues moving between 
two machines.  On my amd64 machine, find returns a long and the slice 
operation expects ulongs.  On my friend's machine, find returns an int 
and refuses to accept cast(ulong)startComment.  Maybe it should be 
cast(uint)startComment?  Of course, that won't work on my machine.

Rather that try to decipher this with version checks (when I don't know 
how this varies from system to system), what's the proper way to solve 
this?  I'm using gdc on my amd64 machine.  I'm not sure if my friend is 
using gdc or dmd... or even if this is a variation form one version of 
phobos to another.

> $ dsss build
> housebot.d => housebot-0.6
> + /bin/rebuild -Idsss_imports/ -I. -S./ -I/include/d -S/lib/   -oqdsss_objs -Dddoc -unittest -w -g housebot.d -ofhousebot-0.6
> warning - gtp.d:105: Error: implicit conversion of expression (startComment) of type long to ulong can cause loss of data
> Command /bin/rebuild returned with code 256, aborting.
> 
> $ head -n 108 gtp.d | tail
> 
>         private void getArgs(out char[][] args){
>                 char[] line = inStream.readLine();
>                 auto startComment = find(line, "#");
>                 char[] commentFree = line;
>                 if (startComment > -1)
>                         commentFree = line[0..startComment];
>                 // Remove starting whitespace, trailing whitespace
>                 // Also replace sequences of spaces and tabs with a single space
>                 char[] squeezedLine = strip(squeeze(tr(line, "\t"," ")," "));


More information about the Digitalmars-d-learn mailing list