C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Common ABI specification

From: samuel ammonius <sfammonius_at_[hidden]>
Date: Fri, 27 Jan 2023 17:41:45 -0330
On Fri, Jan 27, 2023 at 4:36 PM Jonathan Wakely <cxx_at_[hidden]> wrote:

>
>
> On Fri, 27 Jan 2023, 19:24 samuel ammonius via Std-Proposals, <
> std-proposals_at_[hidden]> wrote:
>
>> Hello,
>>
>> I have a proposal that I hope could make C++ possible
>> to mix with different compilers and programming languages
>> without having to use *extern "C"*. It specifies things like
>> name mangling and how "this" is passed to methods, since
>> these things usually get in the way of mixing languages and
>> compilers with C++. It doesn't (shouldn't) interfere with any
>> other language features. I've written a small draft in plaintext
>> that's attached to this email. Thanks.
>>
>
>
> Sorry, but this is never going to work. Your mangling scheme is fatally
> flawed (why not choose one of the existing scheme that actually works?)
>
> > In this case, "radius" will have the symbol "geometry_circle_radius"
>
> So how would you mangle a global variable called "geometry_circle_radius"?
> You can't use valid identifiers as mangled names.
>
> I'm sorry, but this proposal fails to address nearly every important
> aspect of name mangling. Even if we could specify a standardized mangling
> scheme, it wouldn't look like this.
>
> And doing that would not be a pure extension with no impact on the current
> language, because it would require incompatible changes from at least one
> existing, widely-used compiler.
>
>
>
I understand why "geometry_circle_radius" wouldn't work for
name mangling, but valid identifiers shouldn't be outruled completely.
Nearly every programming language uses the same identifier rules
as C++, so it would make mixing languages impossible.

GCC and IBM's C++ compilers use the same system for name
mangling, which uses valid identifiers. It's documented here:
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling
Would that work?

<https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling>
> And doing that would not be a pure extension with no impact on the
current language, because it would require incompatible changes from at
least one
> existing, widely-used compiler.

What about something similar to *extern "C"* for telling compilers
that the symbols are stored this way? (extern "cpp_common_abi")

Received on 2023-01-27 21:11:58