extern opaque struct

Artur Skawina via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 23 22:02:08 PDT 2015


On 08/24/15 00:20, John Colvin via Digitalmars-d wrote:
> Let's say I have some C headers that have code like this in:
> 
> extern struct UndeclaredStruct blah;
> Undeclared *p = &blah;
> 
> which would naïvely translate to D as:
> 
> struct UndeclaredStruct;
> extern UndeclaredStruct blah;
> auto p = &blah;
> 
> which doesn't compile. Why not? Neither the size nor any default initialiser is needed.

Yeah; workaround (plus mangling and TLS fix):

   struct UndeclaredStruct {}
   extern extern (C) __gshared UndeclaredStruct blah;
   auto p = &blah;

artur


More information about the Digitalmars-d mailing list