[cfe-users] Making private types public

Matthew Fernandez via cfe-users cfe-users at lists.llvm.org
Sun Jan 3 16:51:33 PST 2021


> On Jan 3, 2021, at 16:12, Volker Weißmann via cfe-users <cfe-users at lists.llvm.org> wrote:
> 
> Hello,
> 
> If you define a type privately (or protected) like this:
> 
> class c {
> 
>     class priv{};
> 
> };
> 
> then the writing "c::priv" outside of the class c will generate the error "'class c::priv' is private within this context". This is really bad for me, because I'm currently writing a tool that generates Rust-C++ wrappers. I'm thinking of writing a PR, that would add a command line option to clang that would make clang treat all type definitions as if there would be a "public:" in front of them. I'm asking if anyone wants to tell me that this is a bad idea or wants to give me advice.

Maybe I misunderstand your use case, but if you’re generating the C++ why not just generate the inner type as accessible?

    class c {

      public:
        class no_longer_priv{};
    };


More information about the cfe-users mailing list