Cannot compile betterC app in windows using stderr

Steven Schveighoffer schveiguy at gmail.com
Wed Feb 2 14:38:49 UTC 2022


On 2/2/22 7: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`.

I investigated the history of where these are set (in rt/msvc.d), and 
it's fascinating.

I'm not sure why it works on 2.091, though, this setup has existed since 
at least 2015, and probably before. See this PR: 
https://github.com/dlang/druntime/pull/1360

It was changed from a c file to a d file in October 2020 (see 
https://github.com/dlang/druntime/pull/3223), maybe that has something 
to do with it? Though it still shouldn't be running the init_msvc 
function in -betterC, even in 2.091 (which was released before this 
change). I tend to believe that maybe the OP is mistaken that it works, 
or there was a latent bug that was still running some of druntime that 
has been fixed.

-Steve


More information about the Digitalmars-d mailing list