Skip to content

Commit 51b3578

Browse files
committed
FEAT: Visual Studio project using Windows console subsystem by default
1 parent 0455c09 commit 51b3578

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

make/msvc/Make-vs-project.r3

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ vs/Sources: compose/only [
436436
]
437437
vs/IncludePath-x86:
438438
vs/IncludePath-x64: "..\..\..\src\include;"
439-
vs/PreprocessorDefinitions-x86: {TO_WIN32;REB_CORE;REB_EXE;ENDIAN_LITTLE;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;}
440-
vs/PreprocessorDefinitions-x64: {TO_WIN32_X64;__LLP64__;REB_CORE;REB_EXE;ENDIAN_LITTLE;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;}
439+
vs/PreprocessorDefinitions-x86: {WINDOWS_CONSOLE;TO_WIN32;REB_CORE;REB_EXE;ENDIAN_LITTLE;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;}
440+
vs/PreprocessorDefinitions-x64: {WINDOWS_CONSOLE;TO_WIN32_X64;__LLP64__;REB_CORE;REB_EXE;ENDIAN_LITTLE;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;}
441441
vs/Prebuild-x86: {
442442
set REBOL=..\..\prebuild\r3-make-win.exe
443443
set T=../../../src/tools
@@ -464,6 +464,6 @@ set OS_ID=0.3.40
464464
%REBOL% %T%/make-reb-lib.r
465465
}
466466

467-
vs/make-project "Rebol3" %./
467+
vs/make-project/type "Rebol3" %./ "Console"
468468

469469
ask "^/Press ENTER to end."

src/os/host-main.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,28 @@ void Host_Crash(REBYTE *reason) {
112112
***********************************************************************/
113113

114114
#ifdef TO_WINDOWS
115-
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prior, LPSTR cmd, int show)
115+
#ifdef WINDOWS_CONSOLE
116+
int main(int argc, char **argv) {
117+
// Retrieves the window handle used by the console associated with the calling process
118+
HWND hwndC = GetConsoleWindow();
119+
// Then we could just get the HINSTANCE:
120+
App_Instance = GetModuleHandle(0); // HMODULE=HINSTANCE
116121
#else
117-
int main(int argc, char **argv)
118-
#endif
119-
{
120-
REBYTE vers[8];
121-
REBYTE *line;
122-
REBINT n;
123-
124-
#ifdef TO_WINDOWS // In Win32 get args manually:
122+
int APIENTRY WinMain(HINSTANCE inst, HINSTANCE prior, LPSTR cmd, int show) {
125123
int argc;
126124
REBCHR **argv;
127125
// Fetch the win32 unicoded program arguments:
128126
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
129127
App_Instance = inst;
130128
#endif
131129

130+
#else //non Windows platforms
131+
int main(int argc, char **argv) {
132+
#endif
133+
REBYTE vers[8];
134+
REBYTE *line;
135+
REBINT n;
136+
132137
Host_Lib = &Host_Lib_Init;
133138

134139
Parse_Args(argc, (REBCHR **)argv, &Main_Args);

0 commit comments

Comments
 (0)