What should be done? What is expected?
How it is currently in the core/sys/windows/winbase.d
:
BOOL WriteFile(HANDLE, PCVOID, DWORD, PDWORD, LPOVERLAPPED);
How it should be according to Win32 API documentation:
BOOL WriteFile(
HANDLE hFile,
PCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
PDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped
);
The names: hFile
, lpBuffer
, nNumberOfBytesToWrite
, lpNumberOfBytesWritten
, lpOverlapped
are missing.
Why it is important?
Without named arguments you can not use :
syntax to set arguments in the function call.
WriteFile(
hFile: GetStdHandle(STD_OUTPUT_HANDLE),
It is important if you want your interfacing code to be more readable.
Here is a quick example with :
and extern that corrects the winbase.d
definition to allow :
inside function call.
import core.sys.windows.winbase : GetStdHandle, STD_OUTPUT_HANDLE;
extern(Windows) {
import core.sys.windows.basetsd : HANDLE;
import core.sys.windows.windef : BOOL, PCVOID, DWORD, PDWORD;
import core.sys.windows.winbase : LPOVERLAPPED;
BOOL WriteFile(HANDLE hFile, PCVOID lpBuffer, DWORD nNumberOfBytesToWrite, PDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
}
void main(){
string message = "Welcome to D";
uint bytesWritten;
WriteFile(
hFile: GetStdHandle(STD_OUTPUT_HANDLE),
lpBuffer: message.ptr,
nNumberOfBytesToWrite: message.length,
lpNumberOfBytesWritten: &bytesWritten,
lpOverlapped: null
);
}