Skip to content

Fix C++ export resource header ordering - #1674

Open
subotac wants to merge 1 commit into
bytecodealliance:mainfrom
subotac:fix-cpp-export-resource-include-order
Open

Fix C++ export resource header ordering#1674
subotac wants to merge 1 commit into
bytecodealliance:mainfrom
subotac:fix-cpp-export-resource-include-order

Conversation

@subotac

@subotac subotac commented Jul 30, 2026

Copy link
Copy Markdown

The C++ generator added exported resource class headers to the global include list, which is emitted before generated type definitions. As a result, a resource constructor using a generated record
could reference that type before it was defined.

Emit each generated resource header at its position in the topologically sorted header source while keeping the include outside the namespace. Add a code generation regression test for an exported
resource constructor that takes a record parameter.

Testing

  • Generated C++ source compiles successfully with wasi-sdk 30.
  • cargo test --locked -p wit-bindgen-cpp
  • cargo test --locked --workspace --all-targets --exclude wit-bindgen-moonbit
  • cargo clippy --locked --workspace --all-targets -- -D warnings
  • cargo fmt --all -- --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant