Date: Sat, 25 Jan 2025 13:54:51 +0000
On Friday, January 24, 2025, Arthur O'Dwyer wrote:
>
>
> I did see that some uses in LLVM seem like people are writing
> struct MyVec : std::vector<int> {};
> simply as a kind of "mangling firewall," where the "natural" thing to
> write (in the absence of any external constraints) would have been simply:
> using MyVec = std::vector<int>;
> In the latter case the mangled symbol names would have contained
> "std::__1::vector<int, std::__1::allocator<int>>"; in the former case
> they'll simply contain "MyVec", which is (1) shorter, (2) easier to read in
> the debugger, and (3) more stable in case this is a long-lived
> shared-library ABI boundary.
>
Maybe we should be able to specify a specific mangled name:
typedef std::vector<int> MyVec _MangleAs("MyVec");
and maybe we should be able to use 'typedef' for forward declarations much
in the same way we use 'class' for forward declarations. So the header file
would have:
typedef ? MyVec _MangleAs("MyVec");
An alternative syntax might be to play around with extern C, maybe
something like:
extern "C" "MyVec" typedef std::vector<int> MyVec;
I'm sure ChatGPT could suggest another dozen possible syntaxes.
>
>
> I did see that some uses in LLVM seem like people are writing
> struct MyVec : std::vector<int> {};
> simply as a kind of "mangling firewall," where the "natural" thing to
> write (in the absence of any external constraints) would have been simply:
> using MyVec = std::vector<int>;
> In the latter case the mangled symbol names would have contained
> "std::__1::vector<int, std::__1::allocator<int>>"; in the former case
> they'll simply contain "MyVec", which is (1) shorter, (2) easier to read in
> the debugger, and (3) more stable in case this is a long-lived
> shared-library ABI boundary.
>
Maybe we should be able to specify a specific mangled name:
typedef std::vector<int> MyVec _MangleAs("MyVec");
and maybe we should be able to use 'typedef' for forward declarations much
in the same way we use 'class' for forward declarations. So the header file
would have:
typedef ? MyVec _MangleAs("MyVec");
An alternative syntax might be to play around with extern C, maybe
something like:
extern "C" "MyVec" typedef std::vector<int> MyVec;
I'm sure ChatGPT could suggest another dozen possible syntaxes.
Received on 2025-01-25 13:54:53