Hi Liam and Brian,
I’ve been exploring what practical C++ support in FFIgen might look like and ran a small experiment locally to make the ABI constraints concrete.
I implemented a minimal Calculator class and generated a C-compatible wrapper using extern "C" with opaque handles. I built the shared library twice, once with C linkage and once without, and inspected the exported symbols using nm -C.






With extern "C", the wrapper exports clean, stable symbols:
_calculator_add
_calculator_create
_calculator_destroy
Without it, the same functions resolve to ABI-mangled C++ symbols (e.g. __Z14calculator_addP16CalculatorHandlei), which nm -C demangles for readability but remain compiler-specific at the binary level.
Seeing that contrast directly reinforced a few things for me:
Seeing that contrast made it clear to me that C++ name mangling encodes types and context into symbol names, but since each compiler does it differently, the results aren’t consistent. That’s why Dart FFI relies on a stable C ABI surface, so it can interact with native code in a predictable way.
That makes a generated C-compatible wrapper layer feel like the only realistic boundary for interop.
The main question I’m trying to clarify is this:
Do you envision initial C++ support in FFIgen being intentionally limited to a constrained subset of C++ (e.g., non-templated, non-overloaded APIs), or should the wrapper generation aim to systematically expand overloads and templates into distinct C entry points from the start?
If there’s a small real-world C++ library you’d recommend prototyping against, I’d be glad to attempt a minimal parse -> wrapper generation -> Dart binding pipeline and share what I learn.
Best,
Sagar
--
You received this message because you are subscribed to the Google Groups "dart-gsoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dart-gsoc+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dart-gsoc/cc6dcb25-68bd-4336-8f24-bfeb694e286an%40googlegroups.com.