Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 118e298

Browse files
authored
Merge pull request #2389 from WalterBright/WCHAR
use WCHAR instead of wchar_t when interfacing to Windows API merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents 412798c + 26c6c65 commit 118e298

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/rt/dmain2.d

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Contains druntime startup and shutdown routines.
33
*
4-
* Copyright: Copyright Digital Mars 2000 - 2013.
4+
* Copyright: Copyright Digital Mars 2000 - 2018.
55
* License: Distributed under the
66
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
77
* (See accompanying file LICENSE)
@@ -110,7 +110,7 @@ version (Windows)
110110
return initLibrary(.LoadLibraryA(name));
111111
}
112112

113-
extern (C) void* rt_loadLibraryW(const wchar_t* name)
113+
extern (C) void* rt_loadLibraryW(const WCHAR* name)
114114
{
115115
return initLibrary(.LoadLibraryW(name));
116116
}
@@ -382,10 +382,10 @@ extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc)
382382
* Then, reparse into wargc/wargs, and then use Windows API to convert
383383
* to UTF-8.
384384
*/
385-
const wchar_t* wCommandLine = GetCommandLineW();
385+
const wCommandLine = GetCommandLineW();
386386
immutable size_t wCommandLineLength = wcslen(wCommandLine);
387387
int wargc;
388-
wchar_t** wargs = CommandLineToArgvW(wCommandLine, &wargc);
388+
auto wargs = CommandLineToArgvW(wCommandLine, &wargc);
389389
// assert(wargc == argc); /* argc can be broken by Unicode arguments */
390390

391391
// Allocate args[] on the stack - use wargc
@@ -581,7 +581,7 @@ extern (C) void _d_print_throwable(Throwable t)
581581
{
582582
static struct WSink
583583
{
584-
wchar_t* ptr; size_t len;
584+
WCHAR* ptr; size_t len;
585585

586586
void sink(in char[] s) scope nothrow
587587
{
@@ -590,16 +590,16 @@ extern (C) void _d_print_throwable(Throwable t)
590590
CP_UTF8, 0, s.ptr, cast(int)s.length, null, 0);
591591
if (!swlen) return;
592592

593-
auto newPtr = cast(wchar_t*)realloc(ptr,
594-
(this.len + swlen + 1) * wchar_t.sizeof);
593+
auto newPtr = cast(WCHAR*)realloc(ptr,
594+
(this.len + swlen + 1) * WCHAR.sizeof);
595595
if (!newPtr) return;
596596
ptr = newPtr;
597597
auto written = MultiByteToWideChar(
598598
CP_UTF8, 0, s.ptr, cast(int)s.length, ptr+len, swlen);
599599
len += written;
600600
}
601601

602-
wchar_t* get() { if (ptr) ptr[len] = 0; return ptr; }
602+
typeof(ptr) get() { if (ptr) ptr[len] = 0; return ptr; }
603603

604604
void free() { .free(ptr); }
605605
}

0 commit comments

Comments
 (0)