DMD's internal API is unstable and very few people remember there are downstream C++ users of the compiler who rely on the headers being in sync.
There have been arguments over the best way forward to ensure that all contributors relieve the burden on gdc and ldc maintainers when making changes to dmd.
As a compromise, one proposal would be to remove all use of extern(C++) from the Compiler API. In its place would be a single module defining a stable interface for C++.
No attempt is made here to give any idealised view of what such a stable interface should look like, but to give one style as an example:
extern(C++) struct DMDType(T)
{
T impl; // pointer
const(char)* toChars() { return impl.toChars(); }
StorageClass storage_class() { return impl.storage_class; }
BEtype* ctype() { return impl.ctype; }
//...
}
Which will also come with helpers to deal with the initial wrapping of AST nodes from the D types to C++ types.
Comment #1 by robert.schadek — 2024-12-13T19:13:47Z