Interfacing with C in 2.066.1

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 8 08:42:00 PST 2014


"Jason den Dulk"  wrote in message 
news:mobvaeuhbjujojfaycgn at forum.dlang.org...

> Some extra insight.
>
> In the struct "my_bool" is a char alias. I change it to a byte, it 
> compiles. I change it back to char, it dies.

This symbol (`_D6jaypha5dbsql5mysql1c5mysql12st_mysql_res6__initZ') is the 
init data for the struct.

D's char's default value is 0xFF.

When structs can be initialized by memsetting to zero, they don't need an 
init symbol.

So you have a few options:
- Don't use char, use something like bool or ubyte that has 0 as the default 
value.  When interfacing with C you only need to match size (and sometimes 
sign) for C's integral types.
- Give the struct member a default value of false
- Compile the .di file like you do the rest of your source, so the init 
symbol gets found correctly. 



More information about the Digitalmars-d mailing list