diff --git a/CMakeLists.txt b/CMakeLists.txt index bcb7062ae..7935e4710 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ option ( enable-pipewire "compile PipeWire support (if it is available)" on ) option ( enable-readline "compile readline lib line editing (if it is available)" on ) option ( enable-threads "enable multi-threading support (such as parallel voice synthesis)" on ) option ( enable-openmp "enable OpenMP support (parallelization of soundfont decoding, vectorization of voice mixing, etc.)" on ) +option ( enable-unicode "enable UNICODE build for Windows" on ) # Platform specific options if ( CMAKE_SYSTEM MATCHES "Linux" ) @@ -293,7 +294,9 @@ if ( WIN32 OR CYGWIN ) endif() endif () message ( STATUS "Targeting Windows Version ${windows-version}" ) - add_definitions ( -D _UNICODE -D UNICODE ) + if ( enable-unicode ) + add_definitions ( -D _UNICODE -D UNICODE ) + endif () add_definitions ( -D _WIN32_WINNT=${windows-version} ) add_definitions ( -D WINVER=${windows-version} ) list ( APPEND CMAKE_REQUIRED_DEFINITIONS "-DWINVER=${windows-version}" ) diff --git a/src/drivers/fluid_waveout.c b/src/drivers/fluid_waveout.c index 039295f4f..5fe41c7b3 100644 --- a/src/drivers/fluid_waveout.c +++ b/src/drivers/fluid_waveout.c @@ -427,8 +427,11 @@ new_fluid_waveout_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t f if(res == MMSYSERR_NOERROR) { #ifdef _UNICODE - +#ifdef __CYGWIN__ + if(wcscasecmp(lpwDevName, caps.szPname) == 0) +#else if(wcsicmp(lpwDevName, caps.szPname) == 0) +#endif #else if(FLUID_STRCASECMP(dev_name, caps.szPname) == 0) #endif diff --git a/src/drivers/fluid_winmidi.c b/src/drivers/fluid_winmidi.c index 1157d7f10..2f5eefebe 100644 --- a/src/drivers/fluid_winmidi.c +++ b/src/drivers/fluid_winmidi.c @@ -481,8 +481,9 @@ fluid_winmidi_parse_device_name(fluid_winmidi_driver_t *dev, char *dev_name) static void fluid_winmidi_autoconnect_build_name(char *name) { char new_name[MAXPNAMELEN] = { 0 }; - int i, j, n = 0; - int num = midiInGetNumDevs(); + int j; + unsigned int i, n = 0; + unsigned int num = midiInGetNumDevs(); for (i = 0; i < num; ++i) { diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c index e8620b3c8..9b24e56d7 100644 --- a/src/utils/fluid_sys.c +++ b/src/utils/fluid_sys.c @@ -1787,9 +1787,16 @@ fluid_long_long_t fluid_file_tell(FILE* f) #if defined(_WIN32) || defined(__CYGWIN__) // not thread-safe! +#define FLUID_WINDOWS_MEX_ERROR_LEN 1024 + char* fluid_get_windows_error(void) { - static TCHAR err[1024]; +#ifdef _UNICODE + TCHAR err[FLUID_WINDOWS_MEX_ERROR_LEN]; + static char ascii_err[FLUID_WINDOWS_MEX_ERROR_LEN]; +#else + static TCHAR err[FLUID_WINDOWS_MEX_ERROR_LEN]; +#endif FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -1800,8 +1807,6 @@ char* fluid_get_windows_error(void) NULL); #ifdef _UNICODE - static char ascii_err[sizeof(err)]; - WideCharToMultiByte(CP_UTF8, 0, err, -1, ascii_err, sizeof(ascii_err)/sizeof(ascii_err[0]), 0, 0); return ascii_err; #else diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h index cefff4a0a..0672baefd 100644 --- a/src/utils/fluid_sys.h +++ b/src/utils/fluid_sys.h @@ -156,6 +156,12 @@ typedef gintptr intptr_t; #pragma warning(disable : 4996) #endif +/* + * Required by Windows-specific sf_wchar_open() from + * libsndfile that takes a UTF16_BE encoded filename. + */ +#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 + #endif /* Darwin special defines (taken from config_macosx.h) */