473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Union Struct Yields Error

The following struct, DataStruct, is only part of a larger one that contains
additional fields and arrays. I need the explicit layout because this
struct is really a union, where some of the missing fields and arrays
overlap. What's shown here, though, is sufficient for explaining the error.

290 bytes of data come from a serial device and is to be placed in this
struct. Hence, I want this struct to be 290 bytes in size, and, if I'm
adding this right, each of the fields (DataMemb1 thru DataMemb17) are 2
bytes each and the 128-element array of short values, DataArray, is 256
bytes. When I try to use the struct, however, I get the following error:

"Could not load type DataStruct from assembly <filename>,
Version=1.0.0.23184, Culture=neutral, PublicKeyToken=null because it
contains an object field at offset 34 that is incorrectly aligned or
overlapped by a non-object field."

Of course, offset 34 is where the short array, DataArray, begins. If I
manually change it to FieldOffset( 36 ), this error disappears, but I
encounter other problems because the size of the incoming data buffer, 290
bytes, is not equal to the size of the struct, which is now 292 bytes.

Can anyone shed some light on this problem? Thank you!
-Mike
[ StructLayout( LayoutKind.Explicit ) ]
public struct DataStruct
{
[ FieldOffset( 0 ) ]
public ushort DataMemb1;

[ FieldOffset( 2 ) ]
public ushort DataMemb2;

[ FieldOffset( 4 ) ]
public ushort DataMemb3;

[ FieldOffset( 6 ) ]
public ushort DataMemb4;

[ FieldOffset( 8 ) ]
public ushort DataMemb5;

[ FieldOffset( 10 ) ]
public short DataMemb6;

[ FieldOffset( 12 ) ]
public short DataMemb7;

[ FieldOffset( 14 ) ]
public ushort DataMemb8;

[ FieldOffset( 16 ) ]
public short DataMemb9;

[ FieldOffset( 18 ) ]
public short DataMemb10;

[ FieldOffset( 20 ) ]
public ushort DataMemb11;

[ FieldOffset( 22 ) ]
public short DataMemb12;

[ FieldOffset( 24 ) ]
public short DataMemb13;

[ FieldOffset( 26 ) ]
public short DataMemb14;

[ FieldOffset( 28 ) ]
public short DataMemb15;

[ FieldOffset( 30 ) ]
public ushort DataMemb16;

[ FieldOffset( 32 ) ]
public ushort DataMemb17;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 34 ) ]
public short[] DataArray;
}
Nov 15 '05 #1
8 1661
34 % sizeof(void*) != 0. The array must begin on an natural boundary (like
36). You could always read the data out of the serial port 2 bytes at a
type and then allow the runtime to layout the struct more naturally.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike" <mi**@bogus.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
The following struct, DataStruct, is only part of a larger one that contains additional fields and arrays. I need the explicit layout because this
struct is really a union, where some of the missing fields and arrays
overlap. What's shown here, though, is sufficient for explaining the error.
290 bytes of data come from a serial device and is to be placed in this
struct. Hence, I want this struct to be 290 bytes in size, and, if I'm
adding this right, each of the fields (DataMemb1 thru DataMemb17) are 2
bytes each and the 128-element array of short values, DataArray, is 256
bytes. When I try to use the struct, however, I get the following error:

"Could not load type DataStruct from assembly <filename>,
Version=1.0.0.23184, Culture=neutral, PublicKeyToken=null because it
contains an object field at offset 34 that is incorrectly aligned or
overlapped by a non-object field."

Of course, offset 34 is where the short array, DataArray, begins. If I
manually change it to FieldOffset( 36 ), this error disappears, but I
encounter other problems because the size of the incoming data buffer, 290
bytes, is not equal to the size of the struct, which is now 292 bytes.

Can anyone shed some light on this problem? Thank you!
-Mike
[ StructLayout( LayoutKind.Explicit ) ]
public struct DataStruct
{
[ FieldOffset( 0 ) ]
public ushort DataMemb1;

[ FieldOffset( 2 ) ]
public ushort DataMemb2;

[ FieldOffset( 4 ) ]
public ushort DataMemb3;

[ FieldOffset( 6 ) ]
public ushort DataMemb4;

[ FieldOffset( 8 ) ]
public ushort DataMemb5;

[ FieldOffset( 10 ) ]
public short DataMemb6;

[ FieldOffset( 12 ) ]
public short DataMemb7;

[ FieldOffset( 14 ) ]
public ushort DataMemb8;

[ FieldOffset( 16 ) ]
public short DataMemb9;

[ FieldOffset( 18 ) ]
public short DataMemb10;

[ FieldOffset( 20 ) ]
public ushort DataMemb11;

[ FieldOffset( 22 ) ]
public short DataMemb12;

[ FieldOffset( 24 ) ]
public short DataMemb13;

[ FieldOffset( 26 ) ]
public short DataMemb14;

[ FieldOffset( 28 ) ]
public short DataMemb15;

[ FieldOffset( 30 ) ]
public ushort DataMemb16;

[ FieldOffset( 32 ) ]
public ushort DataMemb17;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 34 ) ]
public short[] DataArray;
}

Nov 15 '05 #2
The data is read into a byte[] from the serial port without any trouble, and
before it gets to the point where it moves the data into the struct, the
error occurs. Since the error message indicates a problem in loading it, it
seems that there's something about the layout that isn't right.

Interestingly, when I use this struct with LayoutKind.Sequential (not
requiring the union of remaining data members), it works fine.

Any ideas?
-Mike

"Grant Richins [MS]" <gr*****@online.microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
34 % sizeof(void*) != 0. The array must begin on an natural boundary (like 36). You could always read the data out of the serial port 2 bytes at a
type and then allow the runtime to layout the struct more naturally.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.

"Mike" <mi**@bogus.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
The following struct, DataStruct, is only part of a larger one that

contains
additional fields and arrays. I need the explicit layout because this
struct is really a union, where some of the missing fields and arrays
overlap. What's shown here, though, is sufficient for explaining the

error.

290 bytes of data come from a serial device and is to be placed in this
struct. Hence, I want this struct to be 290 bytes in size, and, if I'm
adding this right, each of the fields (DataMemb1 thru DataMemb17) are 2
bytes each and the 128-element array of short values, DataArray, is 256
bytes. When I try to use the struct, however, I get the following error:
"Could not load type DataStruct from assembly <filename>,
Version=1.0.0.23184, Culture=neutral, PublicKeyToken=null because it
contains an object field at offset 34 that is incorrectly aligned or
overlapped by a non-object field."

Of course, offset 34 is where the short array, DataArray, begins. If I
manually change it to FieldOffset( 36 ), this error disappears, but I
encounter other problems because the size of the incoming data buffer, 290 bytes, is not equal to the size of the struct, which is now 292 bytes.

Can anyone shed some light on this problem? Thank you!
-Mike
[ StructLayout( LayoutKind.Explicit ) ]
public struct DataStruct
{
[ FieldOffset( 0 ) ]
public ushort DataMemb1;

[ FieldOffset( 2 ) ]
public ushort DataMemb2;

[ FieldOffset( 4 ) ]
public ushort DataMemb3;

[ FieldOffset( 6 ) ]
public ushort DataMemb4;

[ FieldOffset( 8 ) ]
public ushort DataMemb5;

[ FieldOffset( 10 ) ]
public short DataMemb6;

[ FieldOffset( 12 ) ]
public short DataMemb7;

[ FieldOffset( 14 ) ]
public ushort DataMemb8;

[ FieldOffset( 16 ) ]
public short DataMemb9;

[ FieldOffset( 18 ) ]
public short DataMemb10;

[ FieldOffset( 20 ) ]
public ushort DataMemb11;

[ FieldOffset( 22 ) ]
public short DataMemb12;

[ FieldOffset( 24 ) ]
public short DataMemb13;

[ FieldOffset( 26 ) ]
public short DataMemb14;

[ FieldOffset( 28 ) ]
public short DataMemb15;

[ FieldOffset( 30 ) ]
public ushort DataMemb16;

[ FieldOffset( 32 ) ]
public ushort DataMemb17;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 34 ) ]
public short[] DataArray;
}


Nov 15 '05 #3
Yes, the runtime won't load the struct because it has 'invalid layout'. The
invalid layout is caused by trying to put a managed object (the array) at an
illegal offset. When you use LayoutKind.Sequential, the runtime will
automatically put in the appropriate padding so that the array starts at a
natural boundary, but then as you rightly pointed out, the managed struct
will not have the same layout as the raw bytes (it will have 2 bytes of
padding between DataMemb17 and DataArray.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike" <mi**@bogus.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
The data is read into a byte[] from the serial port without any trouble, and before it gets to the point where it moves the data into the struct, the
error occurs. Since the error message indicates a problem in loading it, it seems that there's something about the layout that isn't right.

Interestingly, when I use this struct with LayoutKind.Sequential (not
requiring the union of remaining data members), it works fine.

Any ideas?
-Mike

"Grant Richins [MS]" <gr*****@online.microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
34 % sizeof(void*) != 0. The array must begin on an natural boundary

(like
36). You could always read the data out of the serial port 2 bytes at a
type and then allow the runtime to layout the struct more naturally.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no

rights.


"Mike" <mi**@bogus.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
The following struct, DataStruct, is only part of a larger one that

contains
additional fields and arrays. I need the explicit layout because this
struct is really a union, where some of the missing fields and arrays
overlap. What's shown here, though, is sufficient for explaining the

error.

290 bytes of data come from a serial device and is to be placed in this struct. Hence, I want this struct to be 290 bytes in size, and, if I'm adding this right, each of the fields (DataMemb1 thru DataMemb17) are 2 bytes each and the 128-element array of short values, DataArray, is 256 bytes. When I try to use the struct, however, I get the following error:
"Could not load type DataStruct from assembly <filename>,
Version=1.0.0.23184, Culture=neutral, PublicKeyToken=null because it
contains an object field at offset 34 that is incorrectly aligned or
overlapped by a non-object field."

Of course, offset 34 is where the short array, DataArray, begins. If I manually change it to FieldOffset( 36 ), this error disappears, but I
encounter other problems because the size of the incoming data buffer, 290 bytes, is not equal to the size of the struct, which is now 292 bytes.

Can anyone shed some light on this problem? Thank you!
-Mike
[ StructLayout( LayoutKind.Explicit ) ]
public struct DataStruct
{
[ FieldOffset( 0 ) ]
public ushort DataMemb1;

[ FieldOffset( 2 ) ]
public ushort DataMemb2;

[ FieldOffset( 4 ) ]
public ushort DataMemb3;

[ FieldOffset( 6 ) ]
public ushort DataMemb4;

[ FieldOffset( 8 ) ]
public ushort DataMemb5;

[ FieldOffset( 10 ) ]
public short DataMemb6;

[ FieldOffset( 12 ) ]
public short DataMemb7;

[ FieldOffset( 14 ) ]
public ushort DataMemb8;

[ FieldOffset( 16 ) ]
public short DataMemb9;

[ FieldOffset( 18 ) ]
public short DataMemb10;

[ FieldOffset( 20 ) ]
public ushort DataMemb11;

[ FieldOffset( 22 ) ]
public short DataMemb12;

[ FieldOffset( 24 ) ]
public short DataMemb13;

[ FieldOffset( 26 ) ]
public short DataMemb14;

[ FieldOffset( 28 ) ]
public short DataMemb15;

[ FieldOffset( 30 ) ]
public ushort DataMemb16;

[ FieldOffset( 32 ) ]
public ushort DataMemb17;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 34 ) ]
public short[] DataArray;
}



Nov 15 '05 #4
Thanks for your reply, Grant.

Please explain how this works:

1. Why is the padding necessary, and how does one know
when and how much it's used? (I have other arrays and
data members to add to the union.)

2. If the padding is automatic with LayoutKind.Sequential,
then why is the struct's size still 290 bytes?

3. Earlier, you mentioned letting the runtime layout the
struct naturally. How do I expect it to do this?

Thanks.
-Mike
-----Original Message-----
Yes, the runtime won't load the struct because it has 'invalid layout'. Theinvalid layout is caused by trying to put a managed object (the array) at anillegal offset. When you use LayoutKind.Sequential, the runtime willautomatically put in the appropriate padding so that the array starts at anatural boundary, but then as you rightly pointed out, the managed structwill not have the same layout as the raw bytes (it will have 2 bytes ofpadding between DataMemb17 and DataArray.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.

"Mike" <mi**@bogus.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
The data is read into a byte[] from the serial port without any trouble,
and
before it gets to the point where it moves the data into the struct, the error occurs. Since the error message indicates a problem in loading it,
it
seems that there's something about the layout that
isn't right.
Interestingly, when I use this struct with LayoutKind.Sequential (not requiring the union of remaining data members), it works fine.
Any ideas?
-Mike

"Grant Richins [MS]" <gr*****@online.microsoft.com> wrote in message news:%2***************@TK2MSFTNGP11.phx.gbl...
> 34 % sizeof(void*) != 0. The array must begin on an natural boundary
(like
> 36). You could always read the data out of the
serial port 2 bytes at a > type and then allow the runtime to layout the struct more naturally. >
> --
> --Grant
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "Mike" <mi**@bogus.net> wrote in message
> news:%2******************@TK2MSFTNGP09.phx.gbl...
> > The following struct, DataStruct, is only part of a
larger one that > contains
> > additional fields and arrays. I need the explicit layout because this > > struct is really a union, where some of the missing fields and arrays > > overlap. What's shown here, though, is sufficient for explaining the > error.
> >
> > 290 bytes of data come from a serial device and is to be placed inthis > > struct. Hence, I want this struct to be 290 bytes
in size, and, if
I'm > > adding this right, each of the fields (DataMemb1
thru DataMemb17) are
2 > > bytes each and the 128-element array of short
values, DataArray, is
256 > > bytes. When I try to use the struct, however, I
get the following error:
> >
> > "Could not load type DataStruct from assembly
<filename>, > > Version=1.0.0.23184, Culture=neutral, PublicKeyToken=null because it > > contains an object field at offset 34 that is incorrectly aligned or > > overlapped by a non-object field."
> >
> > Of course, offset 34 is where the short array, DataArray, begins. If
I > > manually change it to FieldOffset( 36 ), this error

disappears, but I > > encounter other problems because the size of the incoming data buffer, 290
> > bytes, is not equal to the size of the struct,

which is now 292 bytes. > >
> > Can anyone shed some light on this problem? Thank you! > >
> >
> > -Mike
> >
> >
> > [ StructLayout( LayoutKind.Explicit ) ]
> > public struct DataStruct
> > {
> > [ FieldOffset( 0 ) ]
> > public ushort DataMemb1;
> >
> > [ FieldOffset( 2 ) ]
> > public ushort DataMemb2;
> >
> > [ FieldOffset( 4 ) ]
> > public ushort DataMemb3;
> >
> > [ FieldOffset( 6 ) ]
> > public ushort DataMemb4;
> >
> > [ FieldOffset( 8 ) ]
> > public ushort DataMemb5;
> >
> > [ FieldOffset( 10 ) ]
> > public short DataMemb6;
> >
> > [ FieldOffset( 12 ) ]
> > public short DataMemb7;
> >
> > [ FieldOffset( 14 ) ]
> > public ushort DataMemb8;
> >
> > [ FieldOffset( 16 ) ]
> > public short DataMemb9;
> >
> > [ FieldOffset( 18 ) ]
> > public short DataMemb10;
> >
> > [ FieldOffset( 20 ) ]
> > public ushort DataMemb11;
> >
> > [ FieldOffset( 22 ) ]
> > public short DataMemb12;
> >
> > [ FieldOffset( 24 ) ]
> > public short DataMemb13;
> >
> > [ FieldOffset( 26 ) ]
> > public short DataMemb14;
> >
> > [ FieldOffset( 28 ) ]
> > public short DataMemb15;
> >
> > [ FieldOffset( 30 ) ]
> > public ushort DataMemb16;
> >
> > [ FieldOffset( 32 ) ]
> > public ushort DataMemb17;
> >
> > [ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ] > > [ FieldOffset( 34 ) ]
> > public short[] DataArray;
> > }
> >
> >
>
>


.

Nov 15 '05 #5
answers inline
--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike" <mi**@bogus.net> wrote in message
news:07****************************@phx.gbl...
Thanks for your reply, Grant.

Please explain how this works:

1. Why is the padding necessary, and how does one know
when and how much it's used? (I have other arrays and
data members to add to the union.)
The padding is neccessary to improve perfomance. Even though x86 allows
unaligned memory access (reading a 4-byte integer from a non-4-byte adress
like 0xXXXXXXX1), it performs much better when everything is lined up
properly. As far as how much is used, that gets very tricky. IIRC the ECMA
spec states that this part is completely implementation specific, but the
general rule is that each field's offset should be evenly divisible (no
remainder) by the minimum of the size of the field, or the 'natural integer
size' of the machine. For x86 the 'natural integer size' is 4 bytes. So
field of type byte can appear at any offset, shorts may only appear at even
offsets, ints at 4-byte offsets, etc.

2. If the padding is automatic with LayoutKind.Sequential,
then why is the struct's size still 290 bytes?
I honestly don't know. My best guess is that the runtime is givng you the
marshalling size which isn't the same as the way the struct is layed out in
managed memory.

3. Earlier, you mentioned letting the runtime layout the
struct naturally. How do I expect it to do this?
by using LayoutKind.Sequential like you've already done.

Thanks.
-Mike

Nov 15 '05 #6
Thanks for the answers.

Well, I'd be happy to use LayoutKind.Sequential, but can
this be used when creating a union? I don't know of
another way to layout the union except by using the
Explicit and FieldOffset attributes.
-Mike
-----Original Message-----
answers inline
--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.

"Mike" <mi**@bogus.net> wrote in message
news:07****************************@phx.gbl...
Thanks for your reply, Grant.

Please explain how this works:

1. Why is the padding necessary, and how does one know
when and how much it's used? (I have other arrays and
data members to add to the union.)
The padding is neccessary to improve perfomance. Even

though x86 allowsunaligned memory access (reading a 4-byte integer from a non-4-byte adresslike 0xXXXXXXX1), it performs much better when everything is lined upproperly. As far as how much is used, that gets very tricky. IIRC the ECMAspec states that this part is completely implementation specific, but thegeneral rule is that each field's offset should be evenly divisible (noremainder) by the minimum of the size of the field, or the 'natural integersize' of the machine. For x86 the 'natural integer size' is 4 bytes. Sofield of type byte can appear at any offset, shorts may only appear at evenoffsets, ints at 4-byte offsets, etc.

2. If the padding is automatic with LayoutKind.Sequential, then why is the struct's size still 290 bytes?
I honestly don't know. My best guess is that the runtime

is givng you themarshalling size which isn't the same as the way the struct is layed out inmanaged memory.

3. Earlier, you mentioned letting the runtime layout the
struct naturally. How do I expect it to do this?


by using LayoutKind.Sequential like you've already done.

Thanks.
-Mike

.

Nov 15 '05 #7
Mike,
Well, I'd be happy to use LayoutKind.Sequential, but can
this be used when creating a union?


No, but do you really need that? You dind't have any overlapping
fields in the DataStruct struct. Note that a Sequential struct can be
part of a larger struct with Explicit layout (as long as you follow
the overlapping rules).

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #8
Hi, Mattias,

I didn't include the overlapping members in the original post so that I
could focus my question on the error, but here is the structure in it's
entirety. Can it work as a union? Thanks.
-Mike
[ StructLayout( LayoutKind.Explicit ) ]
public struct DataStruct
{
[ FieldOffset( 0 ) ]
public ushort DataMemb1;

[ FieldOffset( 2 ) ]
public ushort DataMemb2;

[ FieldOffset( 4 ) ]
public ushort DataMemb3;

[ FieldOffset( 6 ) ]
public ushort DataMemb4;

[ FieldOffset( 8 ) ]
public ushort DataMemb5;

[ FieldOffset( 10 ) ]
public short DataMemb6;

[ FieldOffset( 12 ) ]
public short DataMemb7;

[ FieldOffset( 14 ) ]
public ushort DataMemb8;

[ FieldOffset( 16 ) ]
public short DataMemb9;

[ FieldOffset( 18 ) ]
public short DataMemb10;

[ FieldOffset( 20 ) ]
public ushort DataMemb11;

[ FieldOffset( 22 ) ]
public short DataMemb12;

[ FieldOffset( 24 ) ]
public short DataMemb13;

[ FieldOffset( 26 ) ]
public short DataMemb14;

[ FieldOffset( 28 ) ]
public short DataMemb15;

[ FieldOffset( 30 ) ]
public ushort DataMemb16;

[ FieldOffset( 32 ) ]
public ushort DataMemb17;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 34 ) ]
public short[] DataArray;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 290 ) ]
public short[] DataArray2;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 546 ) ]
public short[] DataArray3;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 2 ) ]
[ FieldOffset( 802 ) ]
public ushort[] DataArray4;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 2 ) ]
[ FieldOffset( 802 ) ]
public ushort[] DataArray5;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 802 ) ]
public short[] DataArray6;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 1058 ) ]
public short[] DataArray7;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 128 ) ]
[ FieldOffset( 1314 ) ]
public short[] DataArray8;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 2 ) ]
[ FieldOffset( 1570 ) ]
public ushort[] DataArray9;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 2 ) ]
[ FieldOffset( 1574 ) ]
public ushort[] DataArray10;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 2 ) ]
[ FieldOffset( 1578 ) ]
public ushort[] DataArray11;

[ FieldOffset( 290 ) ]
public ushort DataMemb18;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 4 ) ]
[ FieldOffset( 292 ) ]
public ushort[] DataArray12;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 4 ) ]
[ FieldOffset( 300 ) ]
public ushort[] DataArray13;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 4 ) ]
[ FieldOffset( 308 ) ]
public ushort[] DataArray14;

[ MarshalAs( UnmanagedType.ByValArray, SizeConst = 4 ) ]
[ FieldOffset( 316 ) ]
public ushort[] DataArray15;
}
Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: iceColdFire | last post by:
Hi @all, I am trying to include struct and class objects in a union ,like class A{ int a; A(){} }; struct B {
2
by: Peter Dunker | last post by:
Hi, I will write ANSI C89. Is the following struct defenition correct ? I wrote it with VC6(Windows IDE) and at first no Problem. As I changed a compiler switch to 'no language extension', the...
10
by: tapeesh | last post by:
I created a C file say struct.c with the following structure declarations in the same file struct A { union key { int i; float f; }k1;
8
by: wkaras | last post by:
In my compiler, the following code generates an error: union U { int i; double d; }; U u; int *ip = &u.i; U *up = static_cast<U *>(ip); // error I have to change the cast to...
3
by: John Sasso | last post by:
In my Yacc .y file I defined: %union { int value; struct Symbol Sym; } The Symbol struct I defined in a header file I #included in the Prologue section of the .y file as:
4
by: Michael Brennan | last post by:
I have a menu_item structure containing an union. func is used if the menu item should use a callback, and submenu if a popupmen should be shown. struct menu_item { enum { function, popup }...
2
by: yalbizu | last post by:
#include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; const int NO_OF_STUDENTS=20; struct studentType { string studentFName; string studentLName;
5
by: hnshashi | last post by:
I have writtem kernel(2.4) module to commu. with user space appl. using netlink socket. I am getting compilation error. kernel module:-> #include <linux/skbuff.h> #include<linux/module.h> ...
5
by: Sujal | last post by:
In below program, I'm getting below compilation errors error C2621: member '_tag_nodes_::node_' of union '_tag_nodes_' has copy constructor error C2621: member '_tag_nodes_::linkednode_' of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.