[Gtk-sharp-list] Cross Platform Assemblies?
Charles Iliya Krempeaux
16 Mar 2003 00:12:09 -0800
It would be nice though, if the .dll file could configure
itself at runtime. And change the DllImport statements,
at runtime, to the correct size for the system that it
is running on.
(Of course, this may cause problems if you are "communicating"
between multiple systems with varying architectures [and thus
On Sat, 2003-03-15 at 23:53, Charles Iliya Krempeaux wrote:
> Looking at GLib's "gtypes.h", I see definitions like:
> typedef char gchar;
> typedef short gshort;
> typedef long glong;
> typedef int gint;
> typedef gint gboolean;
> typedef unsigned char guchar;
> typedef unsigned short gushort;
> typedef unsigned long gulong;
> typedef unsigned int guint;
> typedef float gfloat;
> typedef double gdouble;
> Now, what this means is that something like a "gint" is going to be a
> different size on different platforms. (On a x86 architecture it will
> be 32 bits wide. On something else it may be 64 bits wide.)
> Now, in the Gtk# code, we have DllImport statements all over the
> place that make assumptions about the size of these things.
> For instance, we have the C declaration:
> void gtk_widget_set_size_request (GtkWidget *widget,
> gint width,
> gint height);
> And in the Gtk#, this gets turned into:
> static extern
> void gtk_widget_set_size_request(IntPtr raw,
> int width,
> int height);
> Now, this says that a C# "int" is the same as a C "gint".
> Now, on a 32 bit architecture this is true. But, on a 64 bit
> architecture, this isn't!!!
> This is because, on a 64 bit architecture, a C "gint" will be
> 64 bits wide. But the .NET "int" will still be 32 bits wide
> (since it is an alias for "System.Int32".)
> Thus we seem to have a problem.
> This will likely require us to build 32 bit versions, 64 bit versions,
> and possible other size versions, of all our assemblies. (And maybe
> create stub .dll's that link to the correct one at runtime.)
> See ya
Charles Iliya Krempeaux, BSc
Reptile Consulting & Services 604-REPTILE http://www.reptile.ca/