A world that exports a resource taking a record generates a _cpp.h that doesn't compile. The user-class header is #included above the record definitions it references.
Example
Given the following wit:
package foo:bar;
interface my-interface {
record options {
name: string
}
resource my-resource {
constructor(o: options);
}
}
world my-world { export my-interface; }
Generate wit bindings:
wit-bindgen cpp wit --world my-world
Run the output through the compiler
$WASI_SDK_PATH/bin/clang++ --target=wasm32-wasip2 -std=c++23 -fsyntax-only my_world.cpp
Gives the following error:
In file included from my_world.cpp:11:
In file included from ./my_world_cpp.h:4:
./exports-foo-bar-my_interface-MyResource.h:18:36: error: no type named 'Options' in namespace
'exports::foo::bar::my_interface'
18 | MyResource(my_interface::Options o);
| ~~~~~~~~~~~~~~^
./exports-foo-bar-my_interface-MyResource.h:19:42: error: no type named 'Options' in namespace
'exports::foo::bar::my_interface'
19 | static Owned New(my_interface::Options o){return Owned(new MyResource(std::move(o)));}
| ~~~~~~~~~~~~~~^
2 errors generated.
Tested with wit-bindgen v0.59.0
A world that exports a resource taking a record generates a
_cpp.hthat doesn't compile. The user-class header is#included above the record definitions it references.Example
Given the following wit:
Generate wit bindings:
Run the output through the compiler
$WASI_SDK_PATH/bin/clang++ --target=wasm32-wasip2 -std=c++23 -fsyntax-only my_world.cppGives the following error:
Tested with wit-bindgen v0.59.0