C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[=std::interop]] An Annotation for Interoperation with Targets

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Thu, 12 Nov 2026 19:57:26 +0000
I think you need to be a little bit more specific with the proposal.
My understanding of language interop is "it's a dll/so and we agree at the elf/os level what names belong to what function and then we also agree at the machine instruction what is the calling convention, what is the structure of the data being passed (ABI).

It's a difficult proposal since the language has intentional steered away from defining since the details are dependent on other systems not directly in the scope of the C++ language.

Doing it as attributes is not the way the go, as it is my understanding that those are optional and compilers are free to ignore.

The expressivity of the solution is also insufficient, and it will fall into the same pitfalls that make the status quo utterly broken and subject to endless discussions.

For example, you append a [[=std::interop]] to a function with different overloads, now you are kind of stuck with having to define some name mangling rules in order to avoid name colisions.

If instead we define a different type of expression to express an export table that forces to explicitly define what functions overloads get exported and what names they get as well as other optional details like a calling convention (i.e. export table) then this is not even a problem. The linker would be able to resolve all the necessary details.
And the language doesn't even need to know what other types of language exist as long as it is documented somewhere that X language is using Y convention.

And if you have an export table you will also need an import table, which can be combined with the same expression as the export one. But an import expression would also be able to solve another problem, which is the ability to explicitly define from which dll/so from where those symbols should be loaded as opposed to the status quo of having the linker trying to figure out on its own by searching every single library passed to it.

What do you think?



________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of A Johnston via Std-Proposals <std-proposals_at_[hidden]>
Sent: Wednesday, November 11, 2026 7:40:24 AM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: A Johnston <ajohnston54637_at_[hidden]>
Subject: [std-proposals] [[=std::interop]] An Annotation for Interoperation with Targets

Hello,

This is a first draft of a proposal for [[=std::interop]], a standard
annotation marking a declaration for exposure to a foreign execution
environment. There is an optional facility to build up lists of
targets. E.g. [[=std::interop("Python", "Rust")]].

It is intended for use by binding generation tools, and there is a
reference code generator with bindings generated from C++ in plain C,
JavaScript (ECMAScript in the proposal), Python and Rust. The code
generator is just example code, but the outputs would be worth looking
at if you are curious about language bindings.

I have not inquired about a proposal number, and am looking for early
feedback on the proposal.pdf first.

The proposal.pdf is here:
https://whatchamacallem.github.io/std_interop/proposal.pdf

And the website with the source code, generated code and tests is
here: https://whatchamacallem.github.io/std_interop/index.html


Regards,

Adrian
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-11-12 19:59:49