www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - extern opaque struct

reply "John Colvin" <john.loughran.colvin gmail.com> writes:
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.
Aug 23 2015
next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Sunday, 23 August 2015 at 22:20:26 UTC, John Colvin 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.
s/Undeclared /UndeclaredStruct/
Aug 23 2015
prev sibling next sibling parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
"John Colvin"  wrote in message news:uhpgjffttsuqeswyjtam forum.dlang.org...

 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.
It should work, please file in bugzilla.
Aug 23 2015
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Monday, 24 August 2015 at 04:08:28 UTC, Daniel Murphy wrote:
 "John Colvin"  wrote in message 
 news:uhpgjffttsuqeswyjtam forum.dlang.org...

 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.
It should work, please file in bugzilla.
done: https://issues.dlang.org/show_bug.cgi?id=14954
Aug 24 2015
prev sibling parent Artur Skawina via Digitalmars-d <digitalmars-d puremagic.com> writes:
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
Aug 23 2015