Cannot compile betterC app in windows using stderr

Walter Bright newshound2 at digitalmars.com
Wed Feb 2 20:58:25 UTC 2022


On 2/2/2022 4:17 AM, kinke wrote:
> On Wednesday, 2 February 2022 at 07:33:58 UTC, Basile B. wrote:
>> ```d
>> else version (CRuntime_Microsoft)
>> {
>>     ///
>>     shared FILE* stdin;  // = &__iob_func()[0];
>>     ///
>>     shared FILE* stdout; // = &__iob_func()[1];
>>     ///
>>     shared FILE* stderr; // = &__iob_func()[2];
>> }
>> ```
>>
>> shouldn't these variable declarations be `extern` ?
> 
> Nope, they are macros in the MSVC headers, no symbols are available. That's why 
> druntime defines them and sets them up at startup, so they aren't 
> available/linked with `-betterC`.

The trouble is -betterC does not link with druntime, so it can't find stderr. 
The solution is to make stderr a template, so that no linking with druntime is 
necessary.


More information about the Digitalmars-d mailing list