alexcrichton opened PR #10600 from alexcrichton:split-cpp-headers to bytecodealliance:main:
With the merging of the C++ API into this repository in #10582 it opens up some interesting questions about how to organize the C++ API. Externally it was all entirely a single file, but naturally this isn't great for evolution as it's just one giant tangled header. Instead this commit sketches out a possible different path forward which is to provide the C++ API as a sibling to the C API in preexisting header files. For example this moves the
Errorclass to theerror.hheader file as an example.My rough hope would be that in the long-term we could deprecate/remove the
wasmtime.hhheader file and instead "just" have all the C++ APIs in the normal header files (e.g.wasmtime.h). Additionally the split of the C API in separate header files would be amenable to a similar split of the C++ API too where the API you see is basically conditional on the language mode of whatever's including the headers.I'll note though I've not seen prior art in doing this. I'm not aware of any other project which exports both a C and C++ API in its header files. That being said I'm not sure how many other projects would fall in such a bucket.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested fitzgen for a review on PR #10600.
alexcrichton requested wasmtime-core-reviewers for a review on PR #10600.
fitzgen submitted PR review:
I'm a fan of splitting up the monolith C++ header and also the tests, but I am less sold on sharing headers for C and C++. What do you think of having
foo.h-- the C API forfoothingsfoo.hh-- includes the C API, adds the C++ layer on top?
But that said, this is just a soft preference, and I also don't have a ton of experience designing C/C++ libraries, so if there is a better way I am also all ears.
I'm a fan of splitting up the monolith C++ header and also the tests, but I am less sold on sharing headers for C and C++. What do you think of having
* `foo.h` -- the C API for `foo` things * `foo.hh` -- includes the C API, adds the C++ layer on topFWIW that's probably the way I'd go...
alexcrichton updated PR #10600.
alexcrichton updated PR #10600.
alexcrichton commented on PR #10600:
Sounds reasonable to me, updated!
fitzgen submitted PR review:
THanks!
alexcrichton merged PR #10600.
Last updated: Dec 06 2025 at 07:03 UTC