[Mono-bugs] [Bug 79312][Nor] Changed - returning a struct by value giving unexpected results

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Sep 7 16:05:31 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by robertj at gmx.net.

http://bugzilla.ximian.com/show_bug.cgi?id=79312

--- shadow/79312	2006-09-07 14:31:57.000000000 -0400
+++ shadow/79312.tmp.17688	2006-09-07 16:05:31.000000000 -0400
@@ -1,13 +1,13 @@
 Bug#: 79312
 Product: Mono: Runtime
 Version: 1.1
 OS: unknown
 OS Details: Mac OSX 10.4.7, G4
-Status: NEW   
-Resolution: 
+Status: RESOLVED   
+Resolution: NOTABUG
 Severity: Unknown
 Priority: Normal
 Component: interop
 AssignedTo: mono-bugs at ximian.com                            
 ReportedBy: james.eberle at comcast.net               
 QAContact: mono-bugs at ximian.com
@@ -130,6 +130,49 @@
 (e.g. EnumRef), but that is tied to a given word size, so it's not
 32/64 bit friendly.
 
 Thanks for looking at this!
 Jim
 
+
+------- Additional Comments From robertj at gmx.net  2006-09-07 16:05 -------
+Jim, this is not Mono's problem. You're overlooking something:
+
+In C, a function which returns a struct has another calling
+convention than one which returns a pointer to a struct.
+
+If I translate your C# code to C your're trying to
+do this:
+
+typedef struct {
+} foo;
+
+foo function ()
+{
+    foo f;
+    return f;
+}
+
+foo *foo_ptr = (foo *) function ();
+
+This is totally wrong.
+
+
+Since you can't declare "aliases" in C#, you have to live
+with IntPtrs. If you really don't like it, you might write
+wrappers:
+
+public struct EventLoopRef
+{
+   public IntPtr h;
+}
+
+public static EventLoopRef GetCurrentEventLoop ()
+{
+    EventLoopRef result;
+    result.h = GetCurrentEventLoop();
+}
+
+[DllImport(LIB)]
+static extern IntPtr GetCurrentEventLoop();
+
+


More information about the mono-bugs mailing list