vult
vult copied to clipboard
ccode flag generates invalid C (references)
At this point, the vultc generates a mix of C and C++. C doesn't support references, therefore on my platform (RP2040) the compiler complains:
n file included from /home/syso/dev/pico-project-generator/i2s-codec-demo/i2s-codec-demo.c:11:
/home/syso/dev/pico-project-generator/i2s-codec-demo/vult.h:16:59: error: expected ';', ',' or ')' before '&' token
16 | static_inline void Util__ctx_type_0_init(Util__ctx_type_0 &_output_){
| ^
/home/syso/dev/pico-project-generator/i2s-codec-demo/vult.h:23:52: error: expected ';', ',' or ')' before '&' token
23 | static_inline void Util_edge_init(Util__ctx_type_0 &_output_){
| ^
/home/syso/dev/pico-project-generator/i2s-codec-demo/vult.h:28:50: error: expected ';', ',' or ')' before '&' token
28 | static_inline uint8_t Util_edge(Util__ctx_type_0 &_ctx, uint8_t x){
| ^
...
The code generated by the compiler is C++. If you want to call if from C it is necessary to make wrappers for the C++ functions. Take a look at https://isocpp.org/wiki/faq/mixing-c-and-cpp#call-cpp
Basically, you need to create an extern "C" function that takes a pointer and calls the corresponding C++ function passing the reference.
I dropped the support for pure C code because it is easier to generate C++.