ohmu
·
2026-10-15
1extern "C" {
2#include "libc.h"
3}
4
5#ifdef __MINGW32__
6 #include <_mingw.h>
7#endif
8
9template <uint32_t Major, uint32_t Minor>
10struct version_t {
11 static constexpr uint32_t digits(uint32_t n) noexcept {
12 uint32_t len = 1;
13 for (auto temp = n / 10; temp; temp /= 10) {
14 len++;
15 }
16 return len;
17 }
18
19 char buf[digits(Major) + digits(Minor) + 2];
20
21 constexpr version_t() noexcept {
22 auto ptr = buf + sizeof(buf);
23 *--ptr = '\0';
24
25 auto append = [&](uint32_t n) noexcept {
26 if (n == 0) {
27 *--ptr = '0';
28 } else {
29 for (; n; n /= 10) {
30 *--ptr = static_cast<char>('0' + n % 10);
31 }
32 }
33 };
34
35 append(Minor);
36 *--ptr = '.';
37 append(Major);
38 }
39
40 constexpr operator const char*() const noexcept {
41 return buf;
42 }
43};
44
45template <uint32_t Major, uint32_t Minor>
46constexpr version_t<Major, Minor> version;
47
48extern "C" const char* ffDetectLibc(FFLibcResult* result) {
49#ifdef _UCRT
50 result->name = "ucrt";
51#else
52 result->name = "msvcrt";
53#endif
54
55 result->version = version<(__MSVCRT_VERSION__ >> 8), (__MSVCRT_VERSION__ & 0xFF)>;
56 return nullptr;
57}