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

Matt Guo matt at mattguo.com
Tue Jun 9 04:16:21 EDT 2009


Oh, now I understand why.
According to gcc, "int" is always 32bits on both 32 and 64bits sys. "long"
is 32bits on 32 bits sys, and 64bits on 64bits sys. that's
compiler-specific, and if I use other compilers, such as  visual c++, the
result could be different.

On Tue, Jun 9, 2009 at 2:43 PM, Matt Guo <matt at mattguo.com> wrote:

> 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)
>
>


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


More information about the Mono-winforms-list mailing list