The code for this issue is at: https://github.com/itowlson/spin-cpp-wasip2-test
I am trying to build an HTTP handler using WASI 0.2. I used the C++ binding generator from wit-bindgen 0.57.1:
wit-bindgen cpp ./wit/ --out-dir bindings -w http-trigger
and the WASI-SDK 33 compiler:
$(WASI_SDK_PATH)/bin/clang++ -std=c++20 -I bindings -I expected -target wasm32-wasip2 test.cpp bindings/http_trigger.cpp bindings/http_trigger_component_type.o -mexec-model=reactor -o test.wasm
I have patched up expected and wit.h, which has gotten rid of most the first tranche of errors. However, I still get a lot of build errors for generated types for some of my WITs (I think for the Spin APIs, rather than part of WASI), e.g.
./bindings/http_trigger_cpp.h:300:42: error: use of undeclared identifier 'Error'
300 | static std::expected<Connection, Error> Open(std::string_view database);
(The WIT interface here, an API for SQLite, defines an error variant. The .h file does contain an Error type, albeit after this line of code.)
Am I doing something wrong (e.g. wit-bindgen or clang options)? How can I get this generated code to build? Thanks!
(And I'm happy to offer a README for the C++ generator if I can get this working. I could only find one for C so far.)
The code for this issue is at: https://github.com/itowlson/spin-cpp-wasip2-test
I am trying to build an HTTP handler using WASI 0.2. I used the C++ binding generator from wit-bindgen 0.57.1:
and the WASI-SDK 33 compiler:
I have patched up
expectedandwit.h, which has gotten rid of most the first tranche of errors. However, I still get a lot of build errors for generated types for some of my WITs (I think for the Spin APIs, rather than part of WASI), e.g.(The WIT interface here, an API for SQLite, defines an
errorvariant. The.hfile does contain anErrortype, albeit after this line of code.)Am I doing something wrong (e.g. wit-bindgen or clang options)? How can I get this generated code to build? Thanks!
(And I'm happy to offer a README for the C++ generator if I can get this working. I could only find one for C so far.)