зеркало из https://github.com/mono/mail-archives.git
105 строки
3.6 KiB
HTML
105 строки
3.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Mono-osx] fixed in unsafe structs
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20fixed%20in%20unsafe%20structs&In-Reply-To=">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
|
|
<LINK REL="Next" HREF="004554.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Mono-osx] fixed in unsafe structs</H1>
|
|
<B>oleg z</B>
|
|
<A HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20fixed%20in%20unsafe%20structs&In-Reply-To="
|
|
TITLE="[Mono-osx] fixed in unsafe structs">ru.zelyony at gmail.com
|
|
</A><BR>
|
|
<I>Sun May 1 06:20:33 EDT 2011</I>
|
|
<P><UL>
|
|
|
|
<LI>Next message: <A HREF="004554.html">[Mono-osx] How to go from CFStringRef * to C# String
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#4295">[ date ]</a>
|
|
<a href="thread.html#4295">[ thread ]</a>
|
|
<a href="subject.html#4295">[ subject ]</a>
|
|
<a href="author.html#4295">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>//***************************************************************************
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace ConsoleApplication1
|
|
{
|
|
public unsafe struct SomeType
|
|
{
|
|
public int i1, i2, i3;
|
|
|
|
//public fixed int vec[10];
|
|
public fixed long vec[10]; // got a SIGABRT
|
|
}
|
|
|
|
class Program
|
|
{
|
|
|
|
static unsafe void Main( string[] args )
|
|
{
|
|
var c = new SomeType();
|
|
var c2 = new SomeType();
|
|
Console.WriteLine( "sizeof={0}", Marshal.SizeOf( c));
|
|
c.i1 = c2.i1 = 10;
|
|
c.i2 = c2.i2 = 8;
|
|
c.i3 = c2.i3 = 1;
|
|
c.vec[0] = c.vec[5] = c.vec[9] = c2.vec[0] = c2.vec[5] =
|
|
c2.vec[9] = 123;
|
|
Console.WriteLine( "{0} {1} {2} {3} {4} {5} {6} {7}", c.i1,
|
|
c.i2, c.i3, c.vec[0], c.vec[5], c.vec[9], c.vec[3], c.vec[7] );
|
|
Console.WriteLine( "{0} {1} {2} {3} {4} {5} {6} {7}", c2.i1,
|
|
c2.i2, c2.i3, c2.vec[0], c2.vec[5], c2.vec[9], c2.vec[3], c2.vec[7] );
|
|
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
}
|
|
//***************************************************************************
|
|
compile with unsafe context ON console app
|
|
|
|
this code is work incorrectly in MonoFramework 2.10.1.3 sizeof(c) == 24
|
|
(valid 52), and memory(c2) is rewritten from c
|
|
in MonoFramework 2.10.2.5.4 (MDK) code with INT work correctly
|
|
BUT I've got SIGABRT in runtime for LONG arrays (uncomment line in struct
|
|
definition)
|
|
-------------- next part --------------
|
|
An HTML attachment was scrubbed...
|
|
URL: <A HREF="http://lists.ximian.com/pipermail/mono-osx/attachments/20110501/7164cff7/attachment-0001.html">http://lists.ximian.com/pipermail/mono-osx/attachments/20110501/7164cff7/attachment-0001.html</A>
|
|
</PRE>
|
|
|
|
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
|
|
<LI>Next message: <A HREF="004554.html">[Mono-osx] How to go from CFStringRef * to C# String
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#4295">[ date ]</a>
|
|
<a href="thread.html#4295">[ thread ]</a>
|
|
<a href="subject.html#4295">[ subject ]</a>
|
|
<a href="author.html#4295">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx">More information about the Mono-osx
|
|
mailing list</a><br>
|
|
</body></html>
|