[dmd-beta] 32 to 64 bit portability guide

Walter Bright walter at digitalmars.com
Wed Jan 19 13:41:47 PST 2011



Sean Kelly wrote:
> On Jan 15, 2011, at 1:47 PM, Walter Bright wrote:
>
>   
>> A start:
>>
>> http://www.digitalmars.com/d/2.0/32-64-portability.html
>>     
>
> printf("s = '%.*s'\n", s.length, s.ptr); // 32 and 64 bit
>
> Is the above correct?  The above syntax expects an int for the length and s.length will be a ulong.  Or does the compiler do some sort of implicit cast?
>
>   

Yes, it works fine. Both ints and ulongs are passed the same way, in an 
8 byte value. The printf will just read the lower 4 bytes. If you're 
sending a string larger than 4 gigs to printf, you've got other problems :-)


More information about the dmd-beta mailing list