Files
Katayama Hirofumi MZ 0572d36024 [CRT][UCRT][MSVCRT] intrinsic functions: Follow-up of #9157 (#9226)
JIRA issue: CORE-20617
@learn-more found #9157 breaks the build as follows:
> error C2220: the following warning is treated as an error
> warning C4163: 'strncmp': not available as an intrinsic function
> warning C4163: 'strncpy': not available as an intrinsic function
_MSC_VER=1932 was not the version that the intrinsic functions
(strncmp, strncpy, wcsncmp, wcsncpy) added.
Using Compiler Explorer could detect the correct version:
_MSC_VER=1950.
2026-06-29 13:48:51 +09:00

45 lines
933 B
C++

//
// wcsncmp.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Defines wcsncmp(), which compares two wide character strings, determining
// their ordinal order. The function tests at most 'count' characters.
//
// Note that the comparison is performed with unsigned elements (wchar_t is
// unsigned in this implementation), so the null character (0) is less than
// all other characters.
//
// Returns:
// * a negative value if a < b
// * zero if a == b
// * a positive value if a > b
//
#include <string.h>
#if defined(_MSC_VER) && (defined(_M_ARM) || _MSC_VER >= 1950)
#pragma function(wcsncmp)
#endif
extern "C" int __cdecl wcsncmp(
wchar_t const* a,
wchar_t const* b,
size_t count
)
{
if (count == 0)
return 0;
while (--count != 0 && *a && *a == *b)
{
++a;
++b;
}
return static_cast<int>(*a - *b);
}