Skip to content
Snippets Groups Projects
Commit 0d8ef429 authored by Clinton Stimpson's avatar Clinton Stimpson
Browse files

Encoding: Help enforce the use of wide apis on Windows.

Compile flags -DUNICODE and -D_UNICODE are added.
This means that using ANSI or wide apis must be explicit.

Change-Id: Ia0fa72f563e1ee8591f6ca3c02b060abcb801a7c
parent 606d7d6f
No related branches found
No related tags found
No related merge requests found
...@@ -1073,6 +1073,11 @@ IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")) ...@@ -1073,6 +1073,11 @@ IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$"))
) )
ENDIF() ENDIF()
IF(WIN32)
# Help enforce the use of wide Windows apis.
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
ENDIF()
IF(KWSYS_USE_String) IF(KWSYS_USE_String)
# Activate code in "String.c". See the comment in the source. # Activate code in "String.c". See the comment in the source.
SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
......
...@@ -415,7 +415,7 @@ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path) ...@@ -415,7 +415,7 @@ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path)
{ {
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */ /* Implementation for Windows. */
DWORD n = GetFullPathName(in_path, KWSYS_SHARED_FORWARD_MAXPATH, DWORD n = GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH,
out_path, 0); out_path, 0);
return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH; return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH;
#else #else
...@@ -429,9 +429,9 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2) ...@@ -429,9 +429,9 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
{ {
#if defined(_WIN32) #if defined(_WIN32)
int result = 0; int result = 0;
HANDLE h1 = CreateFile(file1, GENERIC_READ, FILE_SHARE_READ, NULL, HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
HANDLE h2 = CreateFile(file2, GENERIC_READ, FILE_SHARE_READ, NULL, HANDLE h2 = CreateFileA(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if(h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE) if(h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE)
{ {
...@@ -462,7 +462,7 @@ static void kwsys_shared_forward_strerror(char* message) ...@@ -462,7 +462,7 @@ static void kwsys_shared_forward_strerror(char* message)
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */ /* Implementation for Windows. */
DWORD original = GetLastError(); DWORD original = GetLastError();
DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | DWORD length = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, FORMAT_MESSAGE_IGNORE_INSERTS, 0, original,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
message, KWSYS_SHARED_FORWARD_MAXPATH, 0); message, KWSYS_SHARED_FORWARD_MAXPATH, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment