[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-03-18 17:29:12 +02:00
parent ff6bd79221
commit deb89436bc
2 changed files with 28 additions and 0 deletions
+5
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)
+23
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 <[email protected]>
*/
#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