Create a better library developing experience with compiler generated interfaces. #871
LouChiSoft
started this conversation in
Suggestions
Replies: 1 comment 5 replies
-
I was wondering if we could use the C++ modules For certain headers (see #594 (comment)), |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Not sure if this would actually be a Cpp2 improvement or a C++ improvement in general. But I figured that if Cpp2 exists in this bubble where no code exists and you can do what you want as Herb said in one of his CPPCon talks on the the matter than this might be a good place to experiment.
I was learning one of the other "C++ successor experiements", Rust, and one of the things I really enjoyed about the language was how easy it is to make shareable crates (libraries). It's not perfect because they are designed to be shared as source rather than as precompiled code which limits it in scenarios where you can't share source code. This has led to several attempts at creating some kind of ABI crate that can take a Rust crate and generate a library for you.
I think that Cpp2/C++ could take this idea and run with it. One of the main improvements Cpp2/C++ could make over the Rust approaches is that in most of the Rust crates they end up using a C library for the stable ABI and then providing a crate that includes wrapped interop functions to call into that C library. Because C++ has a stable ABI that wouldn't be needed.
The two methods I could see being useful would be:
I know it's not necessarily a language feature or function, but I do feel like it would make writing libraries in Cpp2 much simpler and less prone to errors as the compiler would be the one responsible for creating your library interface. Any code changes you make would be automatically reflected in the generated interface file and you would no longer need to mess around with things like
__declspec(dllimport)
etc on Windows for example.Would love feedback on the suggestion.
Beta Was this translation helpful? Give feedback.
All reactions