[STDC++COMPAT] Add rand_s for GCC 13 and pre-NT6 builds

GCC 13 STL requires this.
This commit is contained in:
Timo Kreuzer
2026-01-19 14:06:44 +02:00
parent ff6bd79221
commit deb89436bc
2 changed files with 28 additions and 0 deletions

View File

@@ -7,6 +7,11 @@ list(APPEND SOURCE
__throw_out_of_range_fmt.cpp
StringCchCopyNA.c)
if(DLL_EXPORT_VERSION LESS 0x600)
list(APPEND SOURCE
rand_s.c)
endif()
add_library(stdc++compat ${SOURCE})
set_target_cpp_properties(stdc++compat WITH_EXCEPTIONS)
add_dependencies(stdc++compat xdk)

View File

@@ -0,0 +1,23 @@
/*
* PROJECT: GCC C++ support library
* LICENSE: MIT (https://spdx.org/licenses/MIT)
* PURPOSE: Workaround for missing rand_s on pre-NT6 builds
* COPYRIGHT: Copyright 2026 Timo Kreuzer <timo.kreuzer@reactos.org>
*/
#include <stdlib.h>
errno_t __cdecl rand_s(_Out_ unsigned int *RandomValue)
{
if (!RandomValue)
return EINVAL;
*RandomValue = rand();
return 0;
}
#ifdef _M_IX86
void* _imp__rand_s = rand_s;
#else
void* __imp_rand_s = rand_s;
#endif