8000 cannot open source file "alloca.h" when trying to write a C module for MicroPython · Issue #17271 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

cannot open source file "alloca.h" when trying to write a C module for MicroPython #17271

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

Open
marrowbuster opened this issue May 9, 2025 · 1 comment
Labels

Comments

@marrowbuster
Copy link

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

marrowbuster added a commit to marrowbuster/micropython-epaper that referenced this issue May 9, 2025
@agatti
Copy link
Contributor
agatti commented May 10, 2025

To build examples/natmod/re on Picolibc for RV32 I had to add this:

#if defined __has_builtin
#if __has_builtin(__builtin_alloca)
#define alloca __builtin_alloca
#endif
#endif

#if !defined(alloca)
#if defined(_PICOLIBC__) && !defined(HAVE_BUILTIN_ALLOCA)
#define alloca(n) m_malloc(n)
#else
#include <alloca.h>
#endif
#endif

Maybe this can be adapted to your situation (as in, without the defined(_PICOLIBC__) && … bit in there)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
0