From e9c7dcfc76830ec6cd0983ee765b795075684384 Mon Sep 17 00:00:00 2001 From: pchome Date: Mon, 2 Apr 2018 19:49:03 +0300 Subject: [PATCH] [dxgi] Replace MSVC _countof macro with std::size (#231) * [dxgi] Replace MSVC _countof macro with std::size pro: crosscompiler con: may not work for older clang/gcc/... http://en.cppreference.com/w/cpp/iterator/size For example `Run this code` mode produces errors for GCC-5.2(C++17) and clang-3.8(C++17). Local GCC-7.3 and clang-7 versions are ok. Not tested w/ MinGW64. * [dxgi] Replace MSVC _countof macro with std::size --- src/dxgi/dxgi_adapter.cpp | 2 +- src/dxgi/dxgi_output.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index 9415932e..44861bfd 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -125,7 +125,7 @@ namespace dxvk { } std::memset(pDesc->Description, 0, sizeof(pDesc->Description)); - std::mbstowcs(pDesc->Description, deviceProp.deviceName, _countof(pDesc->Description) - 1); + std::mbstowcs(pDesc->Description, deviceProp.deviceName, std::size(pDesc->Description) - 1); VkDeviceSize deviceMemory = 0; VkDeviceSize sharedMemory = 0; diff --git a/src/dxgi/dxgi_output.cpp b/src/dxgi/dxgi_output.cpp index 759147a5..5159ee0f 100644 --- a/src/dxgi/dxgi_output.cpp +++ b/src/dxgi/dxgi_output.cpp @@ -144,7 +144,7 @@ namespace dxvk { } std::memset(pDesc->DeviceName, 0, sizeof(pDesc->DeviceName)); - std::mbstowcs(pDesc->DeviceName, monInfo.szDevice, _countof(pDesc->DeviceName) - 1); + std::mbstowcs(pDesc->DeviceName, monInfo.szDevice, std::size(pDesc->DeviceName) - 1); pDesc->DesktopCoordinates = monInfo.rcMonitor; pDesc->AttachedToDesktop = 1;