std.stdio.stderr

Antonio Corbi via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 10 09:45:17 PDT 2017


On Saturday, 10 June 2017 at 16:10:18 UTC, Russel Winder wrote:
> It appears that std.stdio.stderr does not wor exactly as stdio 
> stderr
> does. In particular std.stdio.stderr.writef(…) does not work as
> fprintf(stderr…) does.
>
> Some code I am porting from C++ to D makes use of ANSI escape 
> codes to go up a line and overwrite what was there, as well as 
> change colours. This work fine in the C++ code but fails in the 
> D code. The codes are definitely all the same, the only 
> difference is in the writing functions.
>
> Is this problem to be expected or should it work?

Hi Russel,

It seems to work for me with a dumb example:

```
import std.stdio;

void main()
{
   writefln("stdout: %s", "Edit source/app.d to start your 
project.");
   stderr.writefln("stderr: %s", "Edit source/app.d to 
start your project.");
   stderr.writefln("stderr: %s", "Edit source/app.d to 
start your project.");

   stderr.writefln("%s", "");
}
```
Before copy/paste take into account that in sequences like "[7m", 
etc... there's a hidden ESC char at the beginning, something 
like: "\033[7m", and I can't see it in the preview of my posting.

Antonio


More information about the Digitalmars-d-learn mailing list