[Mono-dev] Marshalling: Bug in StructLayout?
vargaz at gmail.com
Sat Aug 18 17:34:48 EDT 2007
This is indeed a mono bug. We align structures smaller than sizeof(void*) to
sizeof(void*) because the JIT memcpy/memset routines require it. So your
AVRational struct has an min alignment of 8 bytes. The workaround for now is to
declare AVRational as having explicit layout.
On 8/18/07, Jonathan Pryor <jonpryor at vt.edu> wrote:
> On Sat, 2007-08-18 at 16:20 +0200, Prakash Punnoor wrote:
> > I am not sure whether I am making something wrong or mono has a bug. Please
> > see attached program. If declare the AVRational struct with explicit offsets,
> > it works, otherwise the width member (and following) in AVFormatContext are
> > off by 4 bytes.
> Out of curiosity, what happens if you remove all attributes, e.g.:
> public struct AVRational
> public int num;
> public int den;
> (The [StructLayout] shouldn't be necessary, as sequential layout is the
> default for structs, and the [MarshalAs] shouldn't be necessary, as, I4
> is the default for `int' as well.)
> - Jon
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list