www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - extern and opaque structs

reply "James Miller" <james aatch.net> writes:
I'm doing C bindings and I have an opaque struct and an extern'd 
variable of the type of that struct. The problem is that dmd is 
complaining that the struct has no definition (which is true). 
Making it a pointer works (expected) but i can't do that because 
the interface is expecting an full struct.

Adding __gshared doesn't help.

I assume this is bug, since usage of extern means that I don't 
need to know the size, since it will be allocated in the C code, 
not the D code.

--
James Miller
May 02 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-05-03 07:00, James Miller wrote:
 I'm doing C bindings and I have an opaque struct and an extern'd
 variable of the type of that struct. The problem is that dmd is
 complaining that the struct has no definition (which is true). Making it
 a pointer works (expected) but i can't do that because the interface is
 expecting an full struct.

 Adding __gshared doesn't help.

 I assume this is bug, since usage of extern means that I don't need to
 know the size, since it will be allocated in the C code, not the D code.

 --
 James Miller
This doesn't work: struct Foo; extern (C) extern Foo foo; -- /Jacob Carlborg
May 03 2012