I seem to be able to crash writefln

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 14 05:57:41 PDT 2011


On Fri, 11 Mar 2011 18:57:32 -0500, Spacen Jasset  
<spacenjasset at yahoo.co.uk> wrote:

> On 10/03/2011 12:18, Steven Schveighoffer wrote:
>> On Wed, 09 Mar 2011 18:19:55 -0500, Joel Christensen <joelcnz at gmail.com>
>> wrote:
>>
>>> This is on Windows 7. Using a def file to stop the terminal window
>>> coming up.
>>>
>>> win.def
>>> EXETYPE NT
>>> SUBSYSTEM WINDOWS
>>>
>>> bug.d
>>> import std.stdio;
>>> import std.string;
>>>
>>> void main() {
>>> auto f = File( "z.txt", "w" );
>>> scope( exit )
>>> f.close;
>>> string foo = "bar";
>>> foreach( n; 0 .. 10 ) {
>>> writefln( "%s", foo );
>>> f.write( format( "count duck-u-lar: %s\n", n ) );
>>> }
>>> }
>>>
>>> output (from in z.txt):
>>> count duck-u-lar: 0
>>
>> If I dust off my rusty old Windows hat, I believe if you try to write to
>> stdout while there is no console window, you will encounter an error.
>>
>> So don't do that ;) I'm not sure what you were expecting...
>>
>> -Steve
> You normally get no output AFAIR using c++ type compiled programs with  
> printf or cout -- and perhaps an error set in cout, but I can't remember  
> about that now.

But don't forget, D uses DMC's runtime, not Visual Studio.  Make sure you  
are comparing to DMC compiled programs.

-Steve


More information about the Digitalmars-d-learn mailing list