Skip to content

Commit

Permalink
[dxgi] Replace MSVC _countof macro with std::size (doitsujin#231)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
pchome authored and doitsujin committed Apr 2, 2018
1 parent 0582e26 commit e9c7dcf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/dxgi/dxgi_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/dxgi/dxgi_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e9c7dcf

Please sign in to comment.