www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Headers, segfaults and other pains PART I

Hello !

Thanks to the help of the many people in these forums I was finally able to
compile an application using the *.d file I made from a *.h . The header file is
for Graphapp - a lightweight GUI API. I really need something like this for my
project. Here is what I did and what goes wrong. I think the main reason is that

I am new to the cryptography of C-headers (I did C++ before but only used simple
headers)

I carefully changed the headerfile according to the manual and the advice of the
people in this forum. Maybe I was not careful enough and should have asked more.
here are the "black" spots.

0. I changed numbers like #define TITLEBAR        0x00000020L
to static int TITLEBAR = 0x00000020 - especially I removed the L
becaue the compiler complained.

1.   I changed definitions like
#define AppExtra void   ---- to     typedef void AppExtra ;
(Alternatively I could use an alias)

2. I changed many const char* occurences in function parameters to 
char* because the compiler complained.

3. I changed things like
#define app_copy_rect(g,dp,src,sr) ((g)->copy_rect((g),(dp),(src),(sr)))

to 

int app_copy_rect(Graphics* g,Point dp,Graphics* src, Rect sr) {
return g.copy_rect(g,dp,src,sr);
}

(As I was told) 

4. I changed the Color stuff like
#define BLACK           rgb(0x00,0x00,0x00)
#define WHITE           rgb(0xFF,0xFF,0xFF)

to

Colour BLACK()            {return rgb(0x00,0x00,0x00);}
Colour WHITE()            {return rgb(0xFF,0xFF,0xFF);}

For 3. and 4. - because the compiler complained - I put these in an extra file
app_help.d, apart from the converted header file app.d.

I compiled with 
dmd ellipses.d -L-lapp -L-lglib -L-lX11

Here ellipses.d is a small app that draws guess what. I had to change some
things in ellipse.d, too. especially, I do the following things which give me
some headaches. (PS: in both ellipse.d and app_help.d i importes app.d and in
ellipsed.d i imported app_help)
May 18 2005