diff --git a/Makefile b/Makefile index df5246b3bc..15270dad32 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ all: rm -rf vc/ git clone --depth 1 --quiet https://github.com/vlang/vc ifdef WIN32 - $(CC) -std=gnu11 -DUNICODE -D_UNICODE -w -o v0.exe vc/v_win.c + $(CC) -std=gnu11 -w -o v0.exe vc/v_win.c ./v0.exe -o v.exe compiler else $(CC) -std=gnu11 -o v vc/v.c -lm diff --git a/compiler/cc.v b/compiler/cc.v index 702982734a..ec37539979 100644 --- a/compiler/cc.v +++ b/compiler/cc.v @@ -173,9 +173,6 @@ fn (v mut V) cc() { a << '-lm' } - if v.os == .windows { - a << '-DUNICODE -D_UNICODE' - } args := a.join(' ') cmd := '${v.pref.ccompiler} $args' // Run @@ -292,7 +289,7 @@ fn (c mut V) cc_windows_cross() { obj_name = obj_name.replace('.exe', '') obj_name = obj_name.replace('.o.o', '.o') include := '-I $winroot/include ' - cmd := 'clang -o $obj_name -w $include -DUNICODE -D_UNICODE -m32 -c -target x86_64-win32 $ModPath/$c.out_name_c' + cmd := 'clang -o $obj_name -w $include -m32 -c -target x86_64-win32 $ModPath/$c.out_name_c' if c.pref.show_c_cmd { println(cmd) } diff --git a/compiler/cheaders.v b/compiler/cheaders.v index 6c7fb6bbe0..9715ed8213 100644 --- a/compiler/cheaders.v +++ b/compiler/cheaders.v @@ -49,6 +49,8 @@ CommonCHeaders = ' #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN +#define _UNICODE +#define UNICODE #include // must be included after diff --git a/compiler/main.v b/compiler/main.v index ce8bd0d7d6..41386bd367 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -333,12 +333,10 @@ fn (v mut V) generate_main() { // vlib can't have `init_consts()` cgen.genln('void init_consts() { #ifdef _WIN32 -#ifndef _BOOTSTRAP_NO_UNICODE_STREAM _setmode(_fileno(stdout), _O_U8TEXT); SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | 0x0004); // ENABLE_VIRTUAL_TERMINAL_PROCESSING #endif -#endif g_str_buf=malloc(1000); $consts_init_body }') diff --git a/compiler/msvc.v b/compiler/msvc.v index 84393dc020..60f80da54f 100644 --- a/compiler/msvc.v +++ b/compiler/msvc.v @@ -225,7 +225,7 @@ pub fn (v mut V) cc_msvc() { // -w: no warnings // 2 unicode defines // /Fo sets the object file name - needed so we can clean up after ourselves properly - mut a := ['-w', '/we4013', '/volatile:ms', '/D_UNICODE', '/DUNICODE', '/Fo"$out_name_obj"'] + mut a := ['-w', '/we4013', '/volatile:ms', '/Fo"$out_name_obj"'] if v.pref.is_prod { a << '/O2' @@ -430,7 +430,7 @@ fn build_thirdparty_obj_file_with_msvc(path string) { //println('cfiles: $cfiles') - cmd := '""$msvc.full_cl_exe_path" /volatile:ms /Z7 $include_string /c $cfiles /Fo"$obj_path" /D_UNICODE /DUNICODE"' + cmd := '""$msvc.full_cl_exe_path" /volatile:ms /Z7 $include_string /c $cfiles /Fo"$obj_path""' //NB: the quotes above ARE balanced. println('thirdparty cmd line: $cmd') res := os.exec(cmd) or { diff --git a/make.bat b/make.bat index 842ab61dfb..0672c7c72e 100644 --- a/make.bat +++ b/make.bat @@ -28,15 +28,15 @@ if not exist "%gccpath%" ( goto:msvcstrap ) -gcc -std=gnu11 -DUNICODE -D_UNICODE -w -o v2.exe vc\v_win.c -if %ERRORLEVEL% GEQ 1 ( +gcc -DUNICODE -D_UNICODE -std=gnu11 -w -o v2.exe vc\v_win.c +if %ERRORLEVEL% NEQ 0 ( echo gcc failed to compile - Create an issue at 'https://github.com/vlang' exit /b 1 ) echo Building v.v... v2.exe -o v.exe compiler -if %ERRORLEVEL% GEQ 1 ( +if %ERRORLEVEL% NEQ 0 ( echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang' exit /b 1 ) @@ -60,16 +60,15 @@ if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" ( goto :nocompiler ) -cl.exe /nologo /w /volatile:ms /D_UNICODE /DUNICODE /Fo.v.c.obj /O2 /MD vc\v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /NOLOGO /OUT:v2.exe /INCREMENTAL:NO - -if %ERRORLEVEL% GEQ 1 ( +cl.exe -DUNICODE -D_UNICODE /nologo /w /volatile:ms /Fo.v.c.obj /O2 /MD vc\v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /NOLOGO /OUT:v2.exe /INCREMENTAL:NO +if %ERRORLEVEL% NEQ 0 ( echo cl.exe failed to build V goto :compileerror ) echo rebuild from source v2.exe -os msvc -o v.exe compiler -if %ERRORLEVEL% GEQ 1 ( +if %ERRORLEVEL% NEQ 0 ( echo V failed to build itself goto :compileerror )