mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:32:59 +00:00
[CRT] Add C++ const correct overloads
This commit is contained in:
parent
8c2b8c835a
commit
8ba61029e1
6 changed files with 167 additions and 7 deletions
|
@ -635,7 +635,7 @@ unsigned int WINAPI
|
||||||
CDownloadManager::ThreadFunc(LPVOID param)
|
CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
{
|
{
|
||||||
CPathW Path;
|
CPathW Path;
|
||||||
PWSTR p, q;
|
PCWSTR p, q;
|
||||||
|
|
||||||
HWND hDlg = static_cast<DownloadParam *>(param)->Dialog;
|
HWND hDlg = static_cast<DownloadParam *>(param)->Dialog;
|
||||||
HWND Item;
|
HWND Item;
|
||||||
|
|
|
@ -1001,10 +1001,10 @@ void CHString::ReleaseBuffer(int nNewLength)
|
||||||
*/
|
*/
|
||||||
int CHString::ReverseFind(CHSTRING_WCHAR ch) const
|
int CHString::ReverseFind(CHSTRING_WCHAR ch) const
|
||||||
{
|
{
|
||||||
CHSTRING_WCHAR *Last;
|
CHSTRING_LPCWSTR Last;
|
||||||
|
|
||||||
// Let's use appropriate helper
|
// Let's use appropriate helper
|
||||||
Last = reinterpret_cast<CHSTRING_WCHAR*>(wcsrchr(reinterpret_cast<LPCWSTR>(m_pchData), ch));
|
Last = reinterpret_cast<CHSTRING_LPCWSTR>(wcsrchr(reinterpret_cast<LPCWSTR>(m_pchData), ch));
|
||||||
// We have to return a position, so compute it
|
// We have to return a position, so compute it
|
||||||
if (Last)
|
if (Last)
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,6 +130,7 @@ namespace std
|
||||||
using ::wcsstr;
|
using ::wcsstr;
|
||||||
using ::wmemchr;
|
using ::wmemchr;
|
||||||
|
|
||||||
|
#ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO
|
||||||
inline wchar_t*
|
inline wchar_t*
|
||||||
wcschr(wchar_t* __p, wchar_t __c)
|
wcschr(wchar_t* __p, wchar_t __c)
|
||||||
{ return wcschr(const_cast<const wchar_t*>(__p), __c); }
|
{ return wcschr(const_cast<const wchar_t*>(__p), __c); }
|
||||||
|
@ -149,4 +150,5 @@ namespace std
|
||||||
inline wchar_t*
|
inline wchar_t*
|
||||||
wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
|
wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
|
||||||
{ return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); }
|
{ return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); }
|
||||||
|
#endif // __CORRECT_ISO_CPP_WCHAR_H_PROTO
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,16 @@
|
||||||
#define NO_OLDNAMES
|
#define NO_OLDNAMES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#define _CRT_DISABLE_GCC_WARNINGS \
|
||||||
|
_Pragma("GCC diagnostic push") \
|
||||||
|
_Pragma("GCC diagnostic ignored \"-Wbuiltin-declaration-mismatch\"") \
|
||||||
|
_Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
|
||||||
|
#define _CRT_RESTORE_GCC_WARNINGS _Pragma("GCC diagnostic pop")
|
||||||
|
#else // __GNUC__
|
||||||
|
#define _CRT_DISABLE_GCC_WARNINGS
|
||||||
|
#define _CRT_RESTORE_GCC_WARNINGS
|
||||||
|
#endif // __GNUC__
|
||||||
|
|
||||||
/** Properties ***************************************************************/
|
/** Properties ***************************************************************/
|
||||||
|
|
||||||
|
@ -132,10 +142,6 @@
|
||||||
#define _AGLOBAL
|
#define _AGLOBAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _CONST_RETURN
|
|
||||||
#define _CONST_RETURN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UNALIGNED
|
#ifndef UNALIGNED
|
||||||
#if defined(__ia64__) || defined(__x86_64) || defined(__arm__) || defined(__arm64__)
|
#if defined(__ia64__) || defined(__x86_64) || defined(__arm__) || defined(__arm64__)
|
||||||
#define UNALIGNED __unaligned
|
#define UNALIGNED __unaligned
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include <corecrt.h>
|
#include <corecrt.h>
|
||||||
|
|
||||||
|
#define __CORRECT_ISO_CPP_STRING_H_PROTO // For stl
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,6 +31,7 @@ extern "C" {
|
||||||
_In_ int _Val,
|
_In_ int _Val,
|
||||||
_In_ size_t _MaxCount);
|
_In_ size_t _MaxCount);
|
||||||
|
|
||||||
|
_CRT_DISABLE_GCC_WARNINGS
|
||||||
_Must_inspect_result_
|
_Must_inspect_result_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
_CONST_RETURN
|
_CONST_RETURN
|
||||||
|
@ -38,6 +41,19 @@ extern "C" {
|
||||||
_In_reads_bytes_opt_(_MaxCount) const void *_Buf,
|
_In_reads_bytes_opt_(_MaxCount) const void *_Buf,
|
||||||
_In_ int _Val,
|
_In_ int _Val,
|
||||||
_In_ size_t _MaxCount);
|
_In_ size_t _MaxCount);
|
||||||
|
_CRT_RESTORE_GCC_WARNINGS
|
||||||
|
|
||||||
|
#if defined __cplusplus
|
||||||
|
extern "C++" _Must_inspect_result_
|
||||||
|
inline void* __CRTDECL memchr(
|
||||||
|
_In_reads_bytes_opt_(_MaxCount) void *_Buf,
|
||||||
|
_In_ int _Val,
|
||||||
|
_In_ size_t _MaxCount)
|
||||||
|
{
|
||||||
|
const void *_Bufc = _Buf;
|
||||||
|
return const_cast<void*>(memchr(_Bufc, _Val, _MaxCount));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_Must_inspect_result_
|
_Must_inspect_result_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
|
@ -174,6 +190,7 @@ extern "C" {
|
||||||
_strdup(
|
_strdup(
|
||||||
_In_opt_z_ const char *_Src);
|
_In_opt_z_ const char *_Src);
|
||||||
|
|
||||||
|
_CRT_DISABLE_GCC_WARNINGS
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
_CONST_RETURN
|
_CONST_RETURN
|
||||||
|
@ -182,6 +199,16 @@ extern "C" {
|
||||||
strchr(
|
strchr(
|
||||||
_In_z_ const char *_Str,
|
_In_z_ const char *_Str,
|
||||||
_In_ int _Val);
|
_In_ int _Val);
|
||||||
|
_CRT_RESTORE_GCC_WARNINGS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
inline char* __CRTDECL strchr(_In_z_ char *_String, _In_ int _Ch)
|
||||||
|
{
|
||||||
|
return const_cast<char*>(strchr(static_cast<const char*>(_String), _Ch));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
|
@ -365,6 +392,7 @@ extern "C" {
|
||||||
int _Val,
|
int _Val,
|
||||||
size_t _MaxCount);
|
size_t _MaxCount);
|
||||||
|
|
||||||
|
_CRT_DISABLE_GCC_WARNINGS
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
_CONST_RETURN
|
_CONST_RETURN
|
||||||
|
@ -373,7 +401,18 @@ extern "C" {
|
||||||
strpbrk(
|
strpbrk(
|
||||||
_In_z_ const char *_Str,
|
_In_z_ const char *_Str,
|
||||||
_In_z_ const char *_Control);
|
_In_z_ const char *_Control);
|
||||||
|
_CRT_RESTORE_GCC_WARNINGS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
inline char* __CRTDECL strpbrk(_In_z_ char *_String, _In_z_ const char *_Control)
|
||||||
|
{
|
||||||
|
return const_cast<char*>(strpbrk(static_cast<const char*>(_String), _Control));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
_CRT_DISABLE_GCC_WARNINGS
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
_CONST_RETURN
|
_CONST_RETURN
|
||||||
|
@ -382,6 +421,16 @@ extern "C" {
|
||||||
strrchr(
|
strrchr(
|
||||||
_In_z_ const char *_Str,
|
_In_z_ const char *_Str,
|
||||||
_In_ int _Ch);
|
_In_ int _Ch);
|
||||||
|
_CRT_RESTORE_GCC_WARNINGS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
inline char* __CRTDECL strrchr(_In_z_ char *_String, _In_ int _Ch)
|
||||||
|
{
|
||||||
|
return const_cast<char*>(strrchr(static_cast<const char*>(_String), _Ch));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
char*
|
char*
|
||||||
|
@ -397,6 +446,7 @@ extern "C" {
|
||||||
_In_z_ const char *_Str,
|
_In_z_ const char *_Str,
|
||||||
_In_z_ const char *_Control);
|
_In_z_ const char *_Control);
|
||||||
|
|
||||||
|
_CRT_DISABLE_GCC_WARNINGS
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
_CONST_RETURN
|
_CONST_RETURN
|
||||||
|
@ -405,6 +455,16 @@ extern "C" {
|
||||||
strstr(
|
strstr(
|
||||||
_In_z_ const char *_Str,
|
_In_z_ const char *_Str,
|
||||||
_In_z_ const char *_SubStr);
|
_In_z_ const char *_SubStr);
|
||||||
|
_CRT_RESTORE_GCC_WARNINGS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_ _Ret_maybenull_
|
||||||
|
inline char* __CRTDECL strstr(_In_z_ char *_String, _In_z_ const char *_SubString)
|
||||||
|
{
|
||||||
|
return const_cast<char*>(strstr(static_cast<const char*>(_String), _SubString));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
|
@ -636,6 +696,16 @@ extern "C" {
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
wchar_t _Ch);
|
wchar_t _Ch);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
_When_(return != NULL, _Ret_range_(_String, _String + _String_length_(_String) - 1))
|
||||||
|
inline wchar_t* __CRTDECL wcschr(_In_z_ wchar_t *_String, wchar_t _C)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcschr(static_cast<const wchar_t*>(_String), _C));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
int
|
int
|
||||||
|
@ -714,6 +784,15 @@ extern "C" {
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
_In_z_ const wchar_t *_Control);
|
_In_z_ const wchar_t *_Control);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
inline wchar_t* __cdecl wcspbrk(_In_z_ wchar_t *_Str, _In_z_ const wchar_t *_Control)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcspbrk(static_cast<const wchar_t*>(_Str), _Control));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
_CONST_RETURN
|
_CONST_RETURN
|
||||||
|
@ -723,6 +802,15 @@ extern "C" {
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
_In_ wchar_t _Ch);
|
_In_ wchar_t _Ch);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
inline wchar_t* __CRTDECL wcsrchr(_In_z_ wchar_t *_String, _In_ wchar_t _C)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcsrchr(static_cast<const wchar_t*>(_String), _C));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
size_t
|
size_t
|
||||||
|
@ -731,6 +819,7 @@ extern "C" {
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
_In_z_ const wchar_t *_Control);
|
_In_z_ const wchar_t *_Control);
|
||||||
|
|
||||||
|
_CRT_DISABLE_GCC_WARNINGS
|
||||||
_When_(return != 0,
|
_When_(return != 0,
|
||||||
_Ret_range_(_Str, _Str + _String_length_(_Str) - 1))
|
_Ret_range_(_Str, _Str + _String_length_(_Str) - 1))
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
|
@ -740,6 +829,17 @@ extern "C" {
|
||||||
wcsstr(
|
wcsstr(
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
_In_z_ const wchar_t *_SubStr);
|
_In_z_ const wchar_t *_SubStr);
|
||||||
|
_CRT_RESTORE_GCC_WARNINGS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_ _Ret_maybenull_
|
||||||
|
_When_(return != NULL, _Ret_range_(_String, _String + _String_length_(_String) - 1))
|
||||||
|
inline wchar_t* __CRTDECL wcsstr(_In_z_ wchar_t *_String, _In_z_ const wchar_t *_SubStr)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcsstr(static_cast<const wchar_t*>(_String), _SubStr));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#define __need___va_list
|
#define __need___va_list
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#define __CORRECT_ISO_CPP_WCHAR_H_PROTO // For stl
|
||||||
|
|
||||||
#pragma pack(push,_CRT_PACKING)
|
#pragma pack(push,_CRT_PACKING)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1926,6 +1928,16 @@ _CRTIMP int __cdecl iswblank(wint_t _C);
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
wchar_t _Ch);
|
wchar_t _Ch);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
_When_(return != NULL, _Ret_range_(_String, _String + _String_length_(_String) - 1))
|
||||||
|
inline wchar_t* __cdecl wcschr(_In_z_ wchar_t *_String, wchar_t _C)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcschr(static_cast<const wchar_t*>(_String), _C));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
int
|
int
|
||||||
__cdecl
|
__cdecl
|
||||||
|
@ -1992,6 +2004,15 @@ _CRTIMP int __cdecl iswblank(wint_t _C);
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
_In_z_ const wchar_t *_Control);
|
_In_z_ const wchar_t *_Control);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
inline wchar_t* __cdecl wcspbrk(_In_z_ wchar_t *_Str, _In_z_ const wchar_t *_Control)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcspbrk(static_cast<const wchar_t*>(_Str), _Control));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
_CONST_RETURN
|
_CONST_RETURN
|
||||||
wchar_t*
|
wchar_t*
|
||||||
|
@ -2000,6 +2021,15 @@ _CRTIMP int __cdecl iswblank(wint_t _C);
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
_In_ wchar_t _Ch);
|
_In_ wchar_t _Ch);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_
|
||||||
|
inline wchar_t* __cdecl wcsrchr(_In_z_ wchar_t *_Str, _In_ wchar_t _Ch)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcsrchr(static_cast<const wchar_t*>(_Str), _Ch));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
size_t
|
size_t
|
||||||
__cdecl
|
__cdecl
|
||||||
|
@ -2014,6 +2044,16 @@ _CRTIMP int __cdecl iswblank(wint_t _C);
|
||||||
_In_z_ const wchar_t *_Str,
|
_In_z_ const wchar_t *_Str,
|
||||||
_In_z_ const wchar_t *_SubStr);
|
_In_z_ const wchar_t *_SubStr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
_Check_return_ _Ret_maybenull_
|
||||||
|
_When_(return != NULL, _Ret_range_(_String, _String + _String_length_(_String) - 1))
|
||||||
|
inline wchar_t* __cdecl wcsstr(_In_z_ wchar_t *_String, _In_z_ const wchar_t *_SubStr)
|
||||||
|
{
|
||||||
|
return const_cast<wchar_t*>(wcsstr(static_cast<const wchar_t*>(_String), _SubStr));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
wchar_t*
|
wchar_t*
|
||||||
__cdecl
|
__cdecl
|
||||||
|
@ -2467,6 +2507,18 @@ __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_T
|
||||||
_In_ wchar_t _C,
|
_In_ wchar_t _C,
|
||||||
_In_ size_t _N);
|
_In_ size_t _N);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C++"
|
||||||
|
inline wchar_t* __cdecl wmemchr(
|
||||||
|
_In_reads_(_N) wchar_t *_S,
|
||||||
|
_In_ wchar_t _C,
|
||||||
|
_In_ size_t _N)
|
||||||
|
{
|
||||||
|
const wchar_t *_SC = _S;
|
||||||
|
return const_cast<wchar_t*>(wmemchr(_SC, _C, _N));
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
int
|
int
|
||||||
__cdecl
|
__cdecl
|
||||||
wmemcmp(
|
wmemcmp(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue