473,785 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.2 3184, 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.Expl icit ) ]
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.B yValArray, SizeConst = 128 ) ]
[ FieldOffset( 34 ) ]
public short[] DataArray;
}
Nov 15 '05 #1
8 1681
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******** **********@TK2M SFTNGP09.phx.gb l...
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.2 3184, 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.Expl icit ) ]
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.B yValArray, 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.Sequ ential (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******** *******@TK2MSFT NGP11.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******** **********@TK2M SFTNGP09.phx.gb l...
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.2 3184, 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.Expl icit ) ]
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.B yValArray, 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.Sequ ential, 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******** ******@TK2MSFTN GP12.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.Sequ ential (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******** *******@TK2MSFT NGP11.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******** **********@TK2M SFTNGP09.phx.gb l...
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.2 3184, 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.Expl icit ) ]
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.B yValArray, 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.Sequ ential,
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.Sequ ential, the runtime willautomaticall y 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******* *******@TK2MSFT NGP12.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.Sequ ential (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******** *******@TK2MSFT NGP11.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******** **********@TK2M SFTNGP09.phx.gb l...
> > 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.2 3184, 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.Expl icit ) ]
> > 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.B yValArray, 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.Sequ ential,
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.Sequ ential like you've already done.

Thanks.
-Mike

Nov 15 '05 #6
Thanks for the answers.

Well, I'd be happy to use LayoutKind.Sequ ential, 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.Sequ ential, 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.Sequ ential like you've already done.

Thanks.
-Mike

.

Nov 15 '05 #7
Mike,
Well, I'd be happy to use LayoutKind.Sequ ential, 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.Expl icit ) ]
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.B yValArray, SizeConst = 128 ) ]
[ FieldOffset( 34 ) ]
public short[] DataArray;

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

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

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

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

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

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

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

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

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

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

[ FieldOffset( 290 ) ]
public ushort DataMemb18;

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

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

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

[ MarshalAs( UnmanagedType.B yValArray, 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
5481
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
5058
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 compiler said that the union has no name. Is it right that in ANSI C the union must be named inside this kind of structure ?
10
11393
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
5664
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 reinterpret_cast for the code
3
11832
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
2593
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 } type; union { int (*func)(int); struct menu_item *submenu; } action;
2
14908
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
6389
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> #include <linux/socket.h> #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h>
5
3867
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 union '_tag_nodes_' has copy constructor Can anybody help me resolve this or any workaround for this? I must need union because in my data structure only one type of node is possible at time. So I have taken union. And ya my data structure
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9958
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.