Hi, everyone,
For Windows NLS sample:
#include <iostream>
#include <Windows.h>
#include <WinNls.h>
#define ARRSIZE(arr) (sizeof(arr)/sizeof(*(arr)))
using namespace std;
int main()
{
wchar_t localeName[LOCALE_NAME_MAX_LENGTH]={0};
cout<<"Calling GetUserDefaultLocaleName";
int ret = GetUserDefaultLocaleName(localeName,ARRSIZE(localeName));
if(ret==0)
cout<<"Cannot retrieve the default locale name."<<endl;
else
wcout<<localeName<<endl;
return 0;
}
got error
test.cpp:13:70: error: 'GetUserDefaultLocaleName' was not declared in this scope
int ret = GetUserDefaultLocaleName(localeName,ARRSIZE(localeName));
^
while there is no such error for builds using ICC and MSVC.
Similar errors (related to <Mingw64>/x8664-w64-mingw32/include/winnls.h) prevent to build recent ICU 59RC:
sh-4.3$ (INSTALLDIR="$PWD/../../GCC64RT" && (./configure --prefix="$INSTALLDIR" --disable-debug --enable-release --disable-shared --enable-static >_configure.log && make >_make.log && make install >_install.log) 2>_stderr.log)
sh-4.3$ make
Note: rebuild with "make VERBOSE=1 " to show all compiler parameters.
make[0]: Making `all' in `stubdata'
make[1]: Entering directory '/c/libICU-59RC/build/source/stubdata'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/c/libICU-59RC/build/source/stubdata'
make[0]: Making `all' in `common'
make[1]: Entering directory '/c/libICU-59RC/build/source/common'
g++ -DHAVE_DLOPEN=0 -DU_HAVE_ATOMIC=1 -DU_HAVE_MMAP=0 -DU_HAVE_STRTOD_L=0 -DU_STATIC_IMPLEMENTATION -I. "-DDEFAULT_ICU_PLUGINS=\"/c/libICU-59RC/build/source/../../GCC64RT/lib/icu\" " -DU_ATTRIBUTE_DEPRECATED= -DU_COMMON_IMPLEMENTATION -O2 -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long -std=c++11 -mthreads -c -o putil.ao putil.cpp
[snip]
putil.cpp:1731:86: error: 'GetUserDefaultLocaleName' was not declared in this scope
int length = GetUserDefaultLocaleName(windowsLocale, UPRV_LENGTHOF(windowsLocale));
^
[snip]
make[1]: *** [../config/mh-mingw64:112: putil.ao] Error 1
make[1]: Leaving directory '/c/libICU-59RC/build/source/common'
make: *** [Makefile:147: all-recursive] Error 2
[snip]
sh-4.3$ make
[snip]
windtfmt.cpp:147:101: error: 'ResolveLocaleName' was not declared in this scope
int length = ResolveLocaleName(bcp47Tag, windowsLocaleName, UPRV_LENGTHOF(windowsLocaleName));
^
[snip]
make[1]: *** [../config/mh-mingw64:112: windtfmt.ao] Error 1
make[1]: Leaving directory '/c/libICU-59RC/build/source/i18n'
make: *** [Makefile:147: all-recursive] Error 2
etc. Not reproduced for ICU 58.2 since it doesn't contain such code.
Could you tell how to fix or bypass this error?
Alexander
After some investigations found the source of error. Build of cpp sample above craches using command
g++ test.cppbut finishes successfully using commandg++ test.cpp -DWINVER=0x601.Futher investigations revealed, that mingw-w64 6.3.0 has definition
WINVER=0x0502(which relate to Windows Server 2003), while MSVC 2015, used for testing, has definitionWINVER=0x0A00(which relate to Windows 10).Could you tell, how most of definitions from
<Mingw64>/x86_64-w64-mingw32/include/winnls.hcould be used, since they requireWINVER=0x0600or higher? I assume this should be described in mingw-w64 documentation, but was unable to find it.Thank you.