Stream: git-wasmtime

Topic: wasmtime / PR #10600 Sketch out merging the C/C++ APIs


view this post on Zulip Wasmtime GitHub notifications bot (Apr 16 2025 at 20:17):

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 Error class to the error.h header file as an example.

My rough hope would be that in the long-term we could deprecate/remove the wasmtime.hh header 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:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Apr 16 2025 at 20:17):

alexcrichton requested fitzgen for a review on PR #10600.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 16 2025 at 20:17):

alexcrichton requested wasmtime-core-reviewers for a review on PR #10600.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2025 at 17:11):

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

?

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.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2025 at 17:35):

ac000 commented on PR #10600:

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 top

FWIW that's probably the way I'd go...

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2025 at 14:33):

alexcrichton updated PR #10600.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2025 at 14:35):

alexcrichton updated PR #10600.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2025 at 14:35):

alexcrichton commented on PR #10600:

Sounds reasonable to me, updated!

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2025 at 19:53):

fitzgen submitted PR review:

THanks!

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2025 at 21:09):

alexcrichton merged PR #10600.


Last updated: Dec 06 2025 at 07:03 UTC