C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Calling C++ functions in a .so directly from foreign languages and C++ as an interface definition language

From: Adrian Johnston <adrian3_at_[hidden]>
Date: Tue, 2 Sep 2025 00:22:21 -0700
re: Sebastian Wittmeier

You should check your email client:
https://lists.isocpp.org/std-proposals/2025/09/15223.php

I am one of those people who is attracted to solving problems that
other people tell me I am not supposed to think about.

C++ already has a mechanism for linkage specification. It is
"dcl.link". Foreign language bindings could be wrapped in a new
linkage type without specifying anything more than that they could be
called from C with certain syntax. Then the compiler could complain if
you went outside the supported subset of C++.

"It is possible to provide custom attributes, a compiler could
interpret them and generate more complete code instead of optimizing
it away."

I already wrote that as part of my research for this proposal. In my
case I do that and then use the same attributes to identify what
bindings need to be generated. That is a whole other rabbit hole
though.

https://github.com/whatchamacallem/hatchlingplatform/blob/main/include/entanglement.h


re: Thiago Macieira

"We already have such data present: the debug symbols. So just read the DWARF
tables and interpret as necessary. See libdwarves for a handy (but incomplete
for C++) implementation."

Very cool. If there was a tool to strip that data down to what was
needed then that would probably meet my requirements for ELF.

Unfortunately, notice the kind of push back I am getting. Without some
commitment to being able to call those kinds of functions on all
platforms, I don't expect the Python or Lua devs to be willing to
consider it.

Received on 2025-09-02 07:22:37