Incomplete types question

NoUseForAName via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 8 04:42:53 PDT 2014


On Tuesday, 8 July 2014 at 11:16:52 UTC, Marc Schütz wrote:
> Your example above doesn't work, because it would be 
> interpreted as a redefinition of the struct. Instead, you can 
> use a public alias to a private type:
>
> // my_module.d:
>
> private struct MyStructImpl {
>     int x;
> }
>
> public alias MyStructPtr = MyStructImpl*;
>
> void doSomething(MyStructPtr foo) {
>     ...
> }
>
> // my_main_program.d:
>
> MyStructPtr bar;    // OK
> MyStructImpl foo;   // Error: my_module.MyStructImpl is private

Thanks, that is what I was looking for.


More information about the Digitalmars-d-learn mailing list