From 8d9d40d621559b9c45ae60d4dafdddb743c49a53 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 6 Mar 2020 14:53:27 +0100 Subject: [PATCH] enable compiling wide char with MINGW --- compile_min.sh | 4 ++-- src/Makefile.am | 1 + src/winmain.c | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/compile_min.sh b/compile_min.sh index 35d1436ba..622ed7287 100755 --- a/compile_min.sh +++ b/compile_min.sh @@ -56,14 +56,14 @@ if test "$1" = "32"; then echo "configuring for 32 bit" echo # You may add --enable-adms to the following command for adding adms generated devices - ../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug --disable-utf8 prefix="C:/Spice" CFLAGS="-m32 -O2" LDFLAGS="-m32 -s" + ../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug prefix="C:/Spice" CFLAGS="-m32 -O2" LDFLAGS="-m32 -s" else cd release if [ $? -ne 0 ]; then echo "cd release failed"; exit 1 ; fi echo "configuring for 64 bit" echo # You may add --enable-adms to the following command for adding adms generated devices - ../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug --disable-utf8 prefix="C:/Spice64" CFLAGS="-m64 -O2" LDFLAGS="-m64 -s" + ../configure --with-wingui --enable-xspice --enable-cider --enable-openmp --disable-debug prefix="C:/Spice64" CFLAGS="-m64 -O2" LDFLAGS="-m64 -s" fi if [ $? -ne 0 ]; then echo "../configure failed"; exit 1 ; fi diff --git a/src/Makefile.am b/src/Makefile.am index 17a07420a..60649913a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -111,6 +111,7 @@ ngspice_SOURCES = \ ngspice_CPPFLAGS = $(AM_CPPFLAGS) -DSIMULATOR if WINGUI +ngspice_LDFLAGS = -municode $(AM_LDFLAGS) ngspice_SOURCES += winmain.c hist_info.c endif diff --git a/src/winmain.c b/src/winmain.c index 849fecdd4..cd5e3cf08 100644 --- a/src/winmain.c +++ b/src/winmain.c @@ -31,8 +31,8 @@ #include #include #include -#ifndef _MSC_VER -#include +#ifdef __MINGW32__ +#include #include #endif @@ -970,7 +970,7 @@ MakeArgcArgv(char *cmdline, int *argc, char ***argv) int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpszCmdLine, _In_ int nCmdShow) #else -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR wlpszCmdLine, _In_ int nCmdShow) #else @@ -998,7 +998,7 @@ WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR n #ifndef EXT_ASC /* convert wchar to utf-8 */ -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) char lpszCmdLine[1024]; WideCharToMultiByte(CP_UTF8, 0, wlpszCmdLine, -1, lpszCmdLine, 1023, NULL, FALSE); #else