https://github.com/kou/mruby/actions/runs/9278121120/job/25528601313#step:4:75
string.c
D:\a\mruby\mruby\src\string.c(859): error C4013: 'malloc' undefined; assuming extern returning int
D:\a\mruby\mruby\src\string.c(859): warning C4312: 'type cast': conversion from 'int' to 'wchar_t *' of greater size
D:\a\mruby\mruby\src\string.c(866): warning C4312: 'type cast': conversion from 'int' to 'char *' of greater size
D:\a\mruby\mruby\src\string.c(868): error C4013: 'free' undefined; assuming extern returning int
D:\a\mruby\mruby\src\string.c(889): warning C4312: 'type cast': conversion from 'int' to 'wchar_t *' of greater size
D:\a\mruby\mruby\src\string.c(895): warning C4312: 'type cast': conversion from 'int' to 'char *' of greater size
If WIN32_LEAN_AND_MEAN is defined, windows.h doesn't include additional headers.
See also: https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers#faster-builds-with-smaller-header-files
It seems that stdlib.h and malloc.h are also excluded with WIN32_LEAN_AND_MEAN. They are required to use malloc().
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/malloc?view=msvc-170#requirements
Routine Required header malloc <stdlib.h>and<malloc.h>
We can choose either of the following solutions:
- Include
<stdlib.h>and<malloc.h>insrc/string.c - Use
mrb_malloc()/mrb_free()instead of rawmalloc()/free()formrb_locale_from_utf8()/mrb_utf8_from_locale()
1. is easy because we can just add 2 lines. But 2. may be better to use our allocation functions in our code base. But 2. breaks backward compatibility.