Severin Teona - SAOC Milestone 3 Updates 2 & 3 - Druntime for Microcontrollers

Severin Teona teona.severin9 at gmail.com
Fri Dec 11 12:51:53 UTC 2020


On Friday, 11 December 2020 at 10:27:29 UTC, IGotD- wrote:

> private extern(C) _reent *__getreent();
>
> FILE* __stdin()() { return cast(FILE*)(__getreent()._stdin); }
> FILE* __stdout()() { return cast(FILE*)(__getreent()._stdout); }
> FILE* __stderr()() { return cast(FILE*)(__getreent()._stderr); }
> ///
> alias __stdin stdin;
> ///
> alias __stdout stdout;
> ///
> alias __stderr stderr;
>
> Is this how you solved stdin/out/err?

Not exactly. I used a struct __sFile_fake for each one of 
stdin/out/err, like in newlib/libc/include/sys/reent.h.

I did this after I compiled a simple C application with the -E 
flag (only preprocessing) and I saw that stdin/out/err were 
translated to _impure_ptr->_stdin/out/err. I searched for these 
symbols in newlib and I found them in reent.h.

I don't know how accurate and right is it, but it seems to link 
the application ok.


More information about the Digitalmars-d mailing list