-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Sketch out merging the C/C++ APIs #10600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sketch out merging the C/C++ APIs #10600
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 forfoo
thingsfoo.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.
FWIW that's probably the way I'd go... |
With the merging of the C++ API into this repository in bytecodealliance#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.
a0cc23b
to
090ac38
Compare
Sounds reasonable to me, updated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THanks!
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 theerror.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.