C++ Logo


Advanced search

Re: [std-proposals] Allow forward declarations of typedef'ed classes

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 20 Feb 2024 20:28:23 +0000
On Tuesday, February 20, 2024, Andrey Erokhin wrote:

I think impossible b/c of name mangling

Name mangling hadn't crossed my mind. I would be fine for 'extern C'
functions though.

Note here though that this is impossible because of something not
acknowledged by the Standard -- name mangling.

However, if I knew that the mangled name was something like
"9InterfaceIXadL_Z3fooIiEiRT_EEE", then I could potentially ask the
compiler to accept a mangled name as a forward declaration, perhaps
something like:

    class IDevice -> InterfaceIXadL_Z3fooIiEiRT_EEE;

And so then if the compiler finds a definition of 'IDevice' further along
in the translation unit, for example:

    typedef Interface<true> IDevice;

then it can issue a diagnostic if the two mangled names don't match.

Received on 2024-02-20 20:28:25