K
kernel_panic
Consider the following code noting the two uses of sizeof():
unsafe struct A
{
int value;
}
unsafe struct B
{
fixed byte value[sizeof(A)]; // Error: 'A' does not have a
predefined size
}
unsafe struct C
{
static void test()
{
int s = sizeof(A); // legal
}
}
If the second sizeof() is legal, why not the first? It seems like it
should be possible for the compiler to determine the size of struct A
at compile time. Is there something I'm missing?
unsafe struct A
{
int value;
}
unsafe struct B
{
fixed byte value[sizeof(A)]; // Error: 'A' does not have a
predefined size
}
unsafe struct C
{
static void test()
{
int s = sizeof(A); // legal
}
}
If the second sizeof() is legal, why not the first? It seems like it
should be possible for the compiler to determine the size of struct A
at compile time. Is there something I'm missing?