cannot open source file "alloca.h" when trying to write a C module for MicroPython
Port, board and/or hardware
rp2 port, Waveshare RP2040-PiZero
MicroPython version
MicroPython v1.25.0 on 2025-04-15; Raspberry Pi Pico with RP2040
Reproduction
Was working on a C module file for MicroPython and included this repo as a submodule but when it got time to #includeing the necessary header files, I got the above error. Apparently it's because alloca.h is only present on Linux and I'm using VSCode on Windows with the MicroPico extension. How shall I remedy this?
Expected behaviour
No response
Observed behaviour
Hovering over the #include "py/runtime.h" file leads to the error cannot open source file "alloca.h" being shown.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
`embed`: Fix `alloca` include for Windows.
Summary
When building the embedded port on MinGW-w64, I receive the following error:
fatal error: alloca.h: No such file or directory
MinGW-w64 (used on MSYS2) doesn't include alloca.h, but alloca() is provided via malloc.h instead. This PR allows the build on this system.
This fix needs be applied on other Windows build systems.
Note: A similar problem affected BSD in the past (see: https://github.com/micropython/micropython/pull/13360).
Testing
We are using MicroPython through KallistiOS, a library for developing on Sega Dreamcast, and more specifically a port in KallistiOS (kos-ports). Previously, it was impossible to compile this port with MinGW-w64 (the foundation of the DreamSDK environment), thanks to this fix, compilation is now possible and the problem is fixed.
<img width="721" height="412" alt="image" src="https://github.com/user-attachments/assets/87d4624d-a68a-4c1c-8a1a-6eabcbc72d6b" />
See: https://github.com/KallistiOS/kos-ports/issues/112