Skip to content

cpp: missing <span> include for list<T> parameters #1481

@kavoc-brown

Description

@kavoc-brown

When a WIT world imports a function that takes a list<T> parameter, wit-bindgen-cpp generates C++ that uses std::span<...> in the public header but does not include <span>. The generated bindings are not self-contained and fail to compile.

poc.wit

package poc:cpp-span;

world w {
  import foo: func(x: list<u8>);
}

Steps:

  1. Generate C++ bindings
  2. Compile to see the error: clang++ -c out/w.cpp -Iout -o out/w.o

Actual result:

error: no member named 'span' in namespace 'std'

wit-bindgen version: 0.50.0

OS: Ubuntu 22.04.5 LTS (x86_64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gen-cppRelated to the C++ code generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions