[Mono-winforms-list] Two XplatUIX11 P/Invoke on 64bits system questiones.

Matt Guo matt at mattguo.com
Tue Jun 9 02:43:05 EDT 2009


1. in Xlib.h, the c declaration of XDefaultDepth is
extern int XDefaultDepth (Display*, int);
              ~~~                                                    ~~~
and in XplatUIX11.cs, the c# declaration of XDefaultScreen is
internal static extern uint XDefaultDepth (IntPtr display, int
screen_number);
                       ~~~~                                ~~~
so as I think, in 64bits system, XDefaultDepth will actually return a 64bits
value, and expect the 2nd param is 64bits, however the dllimported function
will return a 32bit number and pass in a 32bit number as the 2nd param, and
wouldn't it cause any problem? There are many other similiar situation exist
when importing other xlib methods.

2. in XplatUIX11.cs,
internal extern static IntPtr XWhitePixel(IntPtr display, int screen_no);
                        ~~~~~~
internal extern static IntPtr XSetBackground(IntPtr display, IntPtr gc,
UIntPtr background);

~~~~~~~

but in Xlib.h, the c declaration of a color is always "unsigned long", so
why not just use uint to represent a color in c#, and wouldn't IntPtr cause
a problem in 64bits system? (since IntPtr is 64bits in 64bits system,
however "unsigned long" is still 32 bits).


BTW, as I watched, winform seems work fine on 64bits x system (open suse
11.1 64bits), I'm curious why the expected problems are not triggered? And
I'd appreciate it if someone can help to resolve the confusion, thank you.

-- 
B.R.
GUO Rui (Matt)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20090609/b5c741e9/attachment.html 


More information about the Mono-winforms-list mailing list