X header help

Unknown W. Brackets unknown at simplemachines.org
Sat Mar 11 18:32:20 PST 2006


Actually, you want it to be a typedef or alias.  You could just use its:

typedef void (*XIMProc)(XIM, XPointer, XPointer);

Which should be equivalent to:

typedef void function(XIM, XPointer, XPointer) XIMProc;

The important thing here is the typedef; the way you tried doesn't 
specify this is a type, but is more like defining a variable.

Then you would use:

struct XIMCallback
{
	XPointer client_data;
	XIMProc callback;
}

Hope that helps.

Thanks,
-[Unknown]


> Has anyone translated X C headers to D? I have X.h done and Xlib.h is 
> partly done.
> 
> Anyways, I've run into some code that I'm not sure how to translate it 
> to D.
> 
> //----------
> typedef void (*XIMProc)(
>     XIM,
>     XPointer,
>     XPointer
> );
> 
> // then later a struct which uses the above function pointer
> 
> typedef struct {
>     XPointer client_data;
>     XIMProc callback;
> } XIMCallback;
> //----------
> 
> I translated the it as:
> //----------
> void function(XIM, XPointer, XPointer) XIMProc;
> 
> struct XIMCallback
> {
>     XPointer client_data;
>     // XIMProc callback; ??? nope.
>     // void* callback = XIMProc(); ??? nope.
> }
> //----------
> 
> Obviously it failed to compile, but I'm not sure how to translate it.



More information about the Digitalmars-d mailing list