C faults, etc

Walter Bright newshound1 at digitalmars.com
Mon Jul 20 16:15:16 PDT 2009


bearophile wrote:
> writefln, writeln and the things of Tango are nice and cute and safe, but if I have to save 250 MB of numbers (or 1 GB of them, or even more) then performance is important, and those cute functions are 2-3-5 times slower than printf. This means printf can save me minutes of running time. So I use printf. But if I use printf in C and I write:
> 
> int main() {
>     float f = 1.2345;
>     printf("%d\n", f);
>     return 0;
> }
> 
> The compiler says me:
> warning: format '%d' expects type 'int', but argument 2 has type 'double'

This is a non-standard extension to C.

> While DMD compiles it silently. Better to quickly add such warning/error to D compilers too.

D's answer to printf and its problems is writefln.



More information about the Digitalmars-d mailing list