Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 23:25:57 UTC, Nicholas Wilson wrote: `_D10neo4jTypes17neo4j_map_entry_t6__initZ`, or Unions are supposed to be default initialised with the first member, a ulong and thus should be zero initialised. Right, but neo4j_map_entry_t is a struct and that's the one it i

Re: Creating array of structs being used in C interface

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 13:54:54 UTC, Adam D. Ruppe wrote: On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: [...] It is a linker problem because you didn't link to it... D structs have an initializer, even if they are used for interfacing with C. This is a small blob of dat

Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 15:56:13 UTC, Stefan Koch wrote: Does your answer also explain why it works when I move the mytypes.d into the source/ folder? dub will link it in when it is in the source folder. exactly.

Re: Creating array of structs being used in C interface

2016-11-27 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 27 November 2016 at 15:23:33 UTC, Timoses wrote: On Sunday, 27 November 2016 at 14:27:54 UTC, Adam D. Ruppe wrote: That's because int is zero initialized by default and thus doesn't need anything more than a call to zero memory function, and double isn't (it is NaN), so it gets an i

Re: Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
On Sunday, 27 November 2016 at 14:27:54 UTC, Adam D. Ruppe wrote: That's because int is zero initialized by default and thus doesn't need anything more than a call to zero memory function, and double isn't (it is NaN), so it gets an initializer data blob. If you make it = 0 it might work, but e

Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 14:12:31 UTC, Timoses wrote: If I change the union's variable type to "int" (or any other) it compiles just fine. So the problem seems to be the "double" value. That's because int is zero initialized by default and thus doesn't need anything more than a call to

Re: Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
On Sunday, 27 November 2016 at 13:22:36 UTC, Nicholas Wilson wrote: The missing symbol is the struct initialiser for neo4j_map_entry_t. Not sure why is not being generated (it should), possibly because of the union. That seems like a bug please report it. http://issues.dlang.org/ Thanks fo

Re: Creating array of structs being used in C interface

2016-11-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: Why is it a linker problem? I'm not linking to the c interface but merely using D structs... It is a linker problem because you didn't link to it... D structs have an initializer, even if they are used for interfacing with C. This is

Re: Creating array of structs being used in C interface

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: Hi there, I've got a problem interfacing to a C library. The following structs are used by the library's .d file that I've written. struct neo4j_map_entry_t { neo4j_value_t key; neo4j_value_t value; }; s

Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
Hi there, I've got a problem interfacing to a C library. The following structs are used by the library's .d file that I've written. struct neo4j_map_entry_t { neo4j_value_t key; neo4j_value_t value; }; struct neo4j_value_t { uint8_t _vt_off; uint8_t _type;