-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSVC: can't use malloc()
in string.c
with WIN32_LEAN_AND_MEAN
#6277
Comments
kou
added a commit
to kou/mruby
that referenced
this issue
May 29, 2024
…m_utf8(); fix mruby#6277 We need to include stdlib.h and malloc.h to use malloc()/free() but they aren't included in src/string.c with WIN32_LEAN_AND_MEAN. It generates build time warnings. We can solve this by including stdlib.h and malloc.h explicitly or use mrb_malloc()/mrb_free() instead of malloc()/free(). This change uses the latter to use our allocation functions. But this breaks backward compatibility.
#6278 uses the 2. approach. |
#6279 uses the 1. approach. |
matz
added a commit
that referenced
this issue
May 29, 2024
Include headers for malloc() explicitly; fix #6277
I chose #6279 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/kou/mruby/actions/runs/9278121120/job/25528601313#step:4:75
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
andmalloc.h
are also excluded withWIN32_LEAN_AND_MEAN
. They are required to usemalloc()
.https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/malloc?view=msvc-170#requirements
We can choose either of the following solutions:
<stdlib.h>
and<malloc.h>
insrc/string.c
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.
The text was updated successfully, but these errors were encountered: