Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
October 07, 2014 'write' crashes without extra window | ||||
---|---|---|---|---|
| ||||
I have a program that runs at Windows 7 login, each time. But it had been opening with a command prompt, so I got rid of the prompt and now it some times crashes. I've noticed it before, using 'write' without the prompt. |
October 08, 2014 Re: 'write' crashes without extra window | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote:
> I have a program that runs at Windows 7 login, each time. But it had been opening with a command prompt, so I got rid of the prompt and now it some times crashes. I've noticed it before, using 'write' without the prompt.
Can you post the code and the error message (from crash) you're getting?
|
October 08, 2014 Re: 'write' crashes without extra window | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote:
> it had been opening with a command prompt, so I got rid of the prompt and now it some times crashes.
That's a feature - writing to a non-existent handle fails, so it throws an exception. (The reason you don't notice this in something like C is you prolly don't check printf's return value...)
You could just wrap the write function in a try/catch to explicitly ignore the error.
|
October 08, 2014 Re: 'write' crashes without extra window | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 8 October 2014 at 03:33:38 UTC, Adam D. Ruppe wrote:
> On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote:
>> it had been opening with a command prompt, so I got rid of the prompt and now it some times crashes.
>
> That's a feature - writing to a non-existent handle fails, so it throws an exception. (The reason you don't notice this in something like C is you prolly don't check printf's return value...)
>
> You could just wrap the write function in a try/catch to explicitly ignore the error.
Thanks Adam.
|
October 08, 2014 Re: 'write' crashes without extra window | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 8 October 2014 at 03:33:38 UTC, Adam D. Ruppe wrote: > You could just wrap the write function in a try/catch to explicitly ignore the error. Or if the write function is there only for debug purposes you could wrap it in a debug/version block. http://ddili.org/ders/d.en/cond_comp.html |
October 08, 2014 Re: 'write' crashes without extra window | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Wednesday, 8 October 2014 at 09:17:01 UTC, Gary Willoughby
wrote:
> On Wednesday, 8 October 2014 at 03:33:38 UTC, Adam D. Ruppe wrote:
>> You could just wrap the write function in a try/catch to explicitly ignore the error.
>
> Or if the write function is there only for debug purposes you could wrap it in a debug/version block.
>
> http://ddili.org/ders/d.en/cond_comp.html
Yeah, exactly man
|
October 08, 2014 Re: 'write' crashes without extra window | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | Or open nul device in place of stdout (windows equivalent of /dev/null). |
Copyright © 1999-2021 by the D Language Foundation