[Mono-list] void* conversion from IntPtr
akpoon@excite.com
akpoon@excite.com
Thu, 19 Dec 2002 14:28:15 -0500 (EST)
--EXCITEBOUNDARY_000__c21f2946a64f7c5194853d54c2b998aa
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi all,
I tried to compile some unsafe code using mcs, however I am getting
error CS0030: Cannot convert type 'void*' to 'FooStruct*'
However, when I am doing it on VS.NET, it compiles fine. Is there any implicit conversion done in MS compiler that mono doesn't do?
using System;
namespace IntPtr_Conv
{
struct FooStruct
{
int x;
}
class Class1
{
static void Main(string[] args)
{
IntPtr[] pArray = new IntPtr[1]{IntPtr.Zero};
unsafe
{
// works only in MS
FooStruct* s0 = (FooStruct*)(pArray[0]);
// works on both mcs and MS C#
FooStruct* s1 = (FooStruct*)(pArray[0].ToPointer());
}
}
}
}
Thanks
Arnold
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
--EXCITEBOUNDARY_000__c21f2946a64f7c5194853d54c2b998aa
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi all,<br><br> I tried to compile some unsafe code using mcs, however I am getting<br>error CS0030: Cannot convert type 'void*' to 'FooStruct*'<br><br> However, when I am doing it on VS.NET, it compiles fine. Is there any implicit conversion done in MS compiler that mono doesn't do?<br><br>using System;<br><br>namespace IntPtr_Conv<br>{<br> struct FooStruct<br> {<br> int x;<br> }<br><br> class Class1<br> {<br> static void Main(string[] args)<br> {<br> IntPtr[] pArray = new IntPtr[1]{IntPtr.Zero};<br><br> unsafe <br> {<br> // works only in MS<br> FooStruct* s0 = (FooStruct*)(pArray[0]);<br><br> // works on both mcs and MS C#<br> FooStruct* s1 = (FooStruct*)(pArray[0].ToPointer());<br> }<br> }<br> }<br>}<br><br>Thanks<br><br>Arnold<br><p><hr><font size=2 face=geneva><b>Join Excite! - <a href=http://www.excite.com target=_blank>http://www.excite.com</a></b><br>The most personalized portal on the Web!</font>
--EXCITEBOUNDARY_000__c21f2946a64f7c5194853d54c2b998aa--