Re: Error: function std.stdio.setmode is not accessible from module a

2016-11-04 Thread Kirill Kryukov via Digitalmars-d-learn
On Wednesday, 2 November 2016 at 11:17:49 UTC, Jonathan M Davis 
wrote:


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


In case someone else needs this, here is a possible binding:

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

(DIGITAL_MARS_STDIO and MICROSOFT_STDIO seem to be internal to 
std.stdio)




Re: Error: function std.stdio.setmode is not accessible from module a

2016-11-03 Thread Kirill Kryukov via Digitalmars-d-learn
On Thursday, 3 November 2016 at 08:04:45 UTC, Jonathan M Davis 
wrote:

[...]


Thank you for a detailed clarification about setmode 
availability. I'll think more about how to proceed with it, and 
whether I should request it in druntime.


I will try to make a bug report about deprecation.

Thanks!

Kirill


Re: Error: function std.stdio.setmode is not accessible from module a

2016-11-02 Thread Kirill Kryukov via Digitalmars-d-learn
On Wednesday, 2 November 2016 at 11:17:49 UTC, Jonathan M Davis 
wrote:
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


Thanks for the explanation, Jonathan! OK, I'll try adding my own 
binding for the time being, and submit a feature request.


I guess this does not count as regression since it was 
undocumented, as you say. Although I would have thought it was a 
documentation deficiency instead. Working, not obviously wrong 
code stopped working without an alternative method available. 
Perhaps it's OK if it can be added to druntime the future.


Also I am confused by it being both deprecation and error. I 
thought that deprecation message was just a warning about 
something that will stop working in the future, and the code 
should still compile. However in this case dmd first informs me 
that something is deprecated (it's not clear what exactly is 
deprecated). And then immediately fails with an error, on the 
same function call. Is it another separate diagnostic issue, or 
is it working as intended?


Thanks,
Kirill


Error: function std.stdio.setmode is not accessible from module a

2016-11-02 Thread Kirill Kryukov via Digitalmars-d-learn

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?


Thanks,
Kirill