C structs
Johann Lermer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jun 20 03:51:18 PDT 2014
Hi,
I'm fiddling around with cairo (downloaded
fromhttps://github.com/D-Programming-Deimos/cairo) and I stumbled
over this problem:
(file rectandmatrix.d)
----
import deimos.cairo.cairo;
void main ()
{
cairo_rectangle_int_t rect;
cairo_matrix_t matrix;
}
----
Compiling that with 'dmd rectandmatrix' fails with this error:
rectandmatrix.o: In function `_Dmain':
rectandmatrix.d:(.text._Dmain+0x18): undefined reference to
`_D6deimos5cairo5cairo14cairo_matrix_t6__initZ'
collect2: error: ld returned 1 exit status
--- errorlevel 1
The rectangle is OK - no error there. The matrix however,
produces the error. The difference between both is that
cairo_rectangle_int_t is a struct containing integers, and
cairo_matrix_t contains doubles.
I can, however, compile like that:
'dmd rectandmatrix deimos/cairo/cairo.d' (deimos being in a
subdir of the working directory)
then cairo.d is compiled as well and linked to the code.
So, my questions are:
1) Why do I have to compile and link cairo.d - it's only an
definition file for C code and IMHO there shouldn't be any need
to compile cairo.d at all.
2) Why ist a struct containing only integers handled so
differently from a struct holding doubles?
Thanks
More information about the Digitalmars-d-learn
mailing list