D with CygWin
unDEFER via Digitalmars-d
digitalmars-d at puremagic.com
Sat Dec 3 11:53:41 PST 2016
So, just another attempt..
=================================
import std.stdio;
import std.string;
import core.sys.windows.winbase;
extern(C)
{
alias int function(in char*, int, ...) open_t;
open_t _my_open;
extern uint errno;
}
void main()
{
writefln("Open Library");
auto mod = LoadLibrary("C:\\cygwin\\bin\\cygwin1.dll");
if (mod == null)
{
writefln("Failed load cygwin1.dll");
return;
}
writefln("Get Proc");
_my_open = cast(open_t) GetProcAddress(mod, "open");
if (_my_open == null)
{
writefln("Failed open open symbol");
return;
}
writefln("_open");
int res = _my_open(toStringz("/bin/bash"), 0);
writefln("res=%s errno=%s", res, errno);
}
=================================
The code compiles without problem, BUT without last 2 lines it
runs, and with last 2 lines it said that executable is corrupted.
Why???
More information about the Digitalmars-d
mailing list