View previous topic :: View next topic |
Author |
Message |
Insomniak
Joined: 01 Sep 2007 Posts: 16
|
Posted: Wed Jan 16, 2008 8:25 am Post subject: Using X11 lib in D |
|
|
Hi
I'm needing help about how to use X11 lib in D...
I saw in documentation that we can import C functions... But X11 is a bit too complicated, a lot of X11 functions are macros, who are macros of macros, who are macros calling functions...
I don't know how to port the "drawable" thing in D too...
Do i have to write structs like "Display" [they are only pointers...]... ?
Just this :
Code: | extern(C)
{
struct Dislay;
XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
} |
or this... ?
Code: | extern(C)
{
struct Dislay
{
... all members of Display struct
}
XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
} |
So, you understand, i need your help...
(sorry for my bad english... :/)
Thanks in advance. |
|
Back to top |
|
|
miasma
Joined: 08 Feb 2007 Posts: 13
|
Posted: Tue Jan 22, 2008 6:35 pm Post subject: Re: Using X11 lib in D |
|
|
Insomniak wrote: | Hi
I'm needing help about how to use X11 lib in D...
I saw in documentation that we can import C functions... But X11 is a bit too complicated, a lot of X11 functions are macros, who are macros of macros, who are macros calling functions...
I don't know how to port the "drawable" thing in D too...
Do i have to write structs like "Display" [they are only pointers...]... ?
Just this :
Code: | extern(C)
{
struct Dislay;
XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
} |
or this... ?
Code: | extern(C)
{
struct Dislay
{
... all members of Display struct
}
XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
} |
So, you understand, i need your help...
(sorry for my bad english... :/)
Thanks in advance. |
All C preprocessor macros can't be used directly. You need to either rewrite the macros in D (e.g. string mixins) or use wrapper functions.
I think if only pointers to structs are handled in D code, a simple pointer type suffices, but if you need to also access fields, the latter extern(C) block is needed. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|