sizeof struct with array
-
Hi I would like to define a struct with array of int I define the struct as below The problem is that when I want to get the size of the struct, i'm getting it without the array size such as sNDIS_802_16E_ACTIVE m_NDIS_802_16E_ACTIVE; m_NDIS_802_16E_ACTIVE = new sNDIS_802_16E_ACTIVE(20,20); int size = Marshal.SizeOf(m_NDIS_802_16E_ACTIVE); public struct sNDIS_802_16E_ACTIVE { public UInt32 NaplistLength; public UInt32[] Nap; public UInt32 NsplistLength; public UInt32[] Nsp; public byte [] aaa; public sNDIS_802_16E_ACTIVE(UInt32 maxNSP_NAPSize, UInt32 maxNSP_NAPsize) { Nap = new UInt32[maxNSP_NAPSize]; Nsp = new UInt32[maxNSP_NAPSize]; NaplistLength = 0; NsplistLength = 0; } } ; please advice ronen
-
Hi I would like to define a struct with array of int I define the struct as below The problem is that when I want to get the size of the struct, i'm getting it without the array size such as sNDIS_802_16E_ACTIVE m_NDIS_802_16E_ACTIVE; m_NDIS_802_16E_ACTIVE = new sNDIS_802_16E_ACTIVE(20,20); int size = Marshal.SizeOf(m_NDIS_802_16E_ACTIVE); public struct sNDIS_802_16E_ACTIVE { public UInt32 NaplistLength; public UInt32[] Nap; public UInt32 NsplistLength; public UInt32[] Nsp; public byte [] aaa; public sNDIS_802_16E_ACTIVE(UInt32 maxNSP_NAPSize, UInt32 maxNSP_NAPsize) { Nap = new UInt32[maxNSP_NAPSize]; Nsp = new UInt32[maxNSP_NAPSize]; NaplistLength = 0; NsplistLength = 0; } } ; please advice ronen
the size of
public struct sNDIS_802_16E_ACTIVE {
public UInt32 NaplistLength;
public UInt32[] Nap;
public UInt32 NsplistLength;
public UInt32[] Nsp;
public byte [] aaa;
}is 20B on Win32, i.e. 4B for each of the two ints, and 4B for each of the 3 arrays (an array is just a reference, not the data; the data sits elsewhere). :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
the size of
public struct sNDIS_802_16E_ACTIVE {
public UInt32 NaplistLength;
public UInt32[] Nap;
public UInt32 NsplistLength;
public UInt32[] Nsp;
public byte [] aaa;
}is 20B on Win32, i.e. 4B for each of the two ints, and 4B for each of the 3 arrays (an array is just a reference, not the data; the data sits elsewhere). :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Hi But I define the size of the array size in the constructor Should the size of the member of the struct include array definitions? Ronen
I don't understand your question. In THAT struct, under Win32, each member takes 4 bytes, either for an int value, or for a reference. The size of the arrays themselves is irrelevant inside the struct, as they are separate objects. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
I don't understand your question. In THAT struct, under Win32, each member takes 4 bytes, either for an int value, or for a reference. The size of the arrays themselves is irrelevant inside the struct, as they are separate objects. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages