Skip to content

Commit 479662e

Browse files
authored
GH-47590: [C++] Use W functions explicitly for Windows UNICODE compatibility (#47593)
### Rationale for this change Windows build breaks when UNICODE is defined. The codebase mixes explicit Wide APIs with generic ones, causing compile errors. ### What changes are included in this PR? Fixed two API calls to use explicit Wide versions: - `cpu_info.cc`: `GetModuleHandle("kernel32")` → `GetModuleHandleW(L"kernel32")` - `io_util.cc`: `CreateFileMapping(..., "")` → `CreateFileMappingW(..., L"")` ### Are these changes tested? Yes. Built on Windows 11 with MSVC 2022. Tested with: ``` cmake .. --preset ninja-debug-minimal -DCMAKE_CXX_FLAGS="-DUNICODE -D_UNICODE" cmake --build . ``` Build completes successfully: ``` [197/197] Linking CXX shared library debug\arrow.dll ``` Also verified the build still works without UNICODE defined. ### Are there any user-facing changes? No. Just fixes a compile error. - [#47590 ](#47590) * GitHub Issue: #47590 Authored-by: aLVINlEE9 <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
1 parent c7cea52 commit 479662e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cpp/src/arrow/util/cpu_info.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void OsRetrieveCacheSize(std::array<int64_t, kCacheLevels>* cache_sizes) {
8282
typedef BOOL(WINAPI * GetLogicalProcessorInformationFuncPointer)(void*, void*);
8383
GetLogicalProcessorInformationFuncPointer func_pointer =
8484
(GetLogicalProcessorInformationFuncPointer)GetProcAddress(
85-
GetModuleHandle("kernel32"), "GetLogicalProcessorInformation");
85+
GetModuleHandleW(L"kernel32"), "GetLogicalProcessorInformation");
8686

8787
if (!func_pointer) {
8888
ARROW_LOG(WARNING) << "Failed to find procedure GetLogicalProcessorInformation";

cpp/src/arrow/util/io_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ Status MemoryMapRemap(void* addr, size_t old_size, size_t new_size, int fildes,
14481448

14491449
SetFilePointer(h, new_size_low, &new_size_high, FILE_BEGIN);
14501450
SetEndOfFile(h);
1451-
fm = CreateFileMapping(h, NULL, PAGE_READWRITE, 0, 0, "");
1451+
fm = CreateFileMappingW(h, NULL, PAGE_READWRITE, 0, 0, L"");
14521452
if (fm == NULL) {
14531453
return StatusFromMmapErrno("CreateFileMapping failed");
14541454
}

0 commit comments

Comments
 (0)