On Wednesday, November 02, 2016 08:58:04 Kirill Kryukov via Digitalmars-d-
learn wrote:
> Hello,
>
> dmd 2.072.0 broke my project. I reduced it to following:
>
> ===== a.d start =====
> import std.stdio;
>
> void main()
> {
>      setmode(stdin.fileno, 0x8000);
> }
> ===== a.d end =====
>
> Compiling on Windows 7 64-bit with the following commands:
>
> C:\utl\dev\D\dmd-2.071.2\windows\bin\dmd.exe a.d -ofa1.exe
> C:\utl\dev\D\dmd-2.072.0\windows\bin\dmd.exe a.d -ofa2.exe
>
> The first one succeeds (producing a working executable), the
> second one fails with these messages:
>
> a.d(6): Deprecation: std.stdio.setmode is not visible from module
> a
> a.d(6): Error: function std.stdio.setmode is not accessible from
> module a
>
> 2.072.0 changelog does not seem to mention anything relevant. Is
> there something obvious I'm missing, or should I file a bug
> report?

setmode was never publicly documented, and technically, you weren't supposed
to be using it from there (since it wasn't documented). It was fixed in
2.072.0 so that all of the undocumented stuff in std.stdio was made private.
It was never intended that setmode be part of the public API in std.stdio.
But of course, since you were using it in spite of it being undocumented,
your code broke.

Now, setmode is a C function from Windows, so it should be in druntime where
you could easily import it, but unfortunately, it looks like it's currently
missing from there. Rather, the bindings for it were just put directly in
std.stdio instead of in druntime where they belongs. So, if anything, the
bug is that druntime doesn't have it. So, it would make sense to open a bug
for that. But if you want to still use it without it being in druntime, you
can just declare the bindings yourself, as annoying as that may be. e.g.
this is essentially what's in std.stdio:

version(DIGITAL_MARS_STDIO)
    extern(C) int setmode(int, int) nothrow @nogc;
else version(MICROSOFT_STDIO)
{
    extern(C) int _setmode(int, int) nothrow @nogc;
    alias setmode = _setmode;
}

It really should be put in druntime though.

- Jonathan M Davis

Reply via email to