X hits on this document

861 views

0 shares

0 downloads

0 comments

340 / 396

Chapter ‎18   Unsafe code

sizeof(ushort)

2

sizeof(int)

4

sizeof(uint)

4

sizeof(long)

8

sizeof(ulong)

8

sizeof(char)

2

sizeof(float)

4

sizeof(double)

8

sizeof(bool)

1

For all other types, the result of the sizeof operator is implementation-defined and is classified as a value, not a constant.

The order in which members are packed into a struct is unspecified.

For alignment purposes, there may be unnamed padding at the beginning of a struct, within a struct, and at the end of the struct. The contents of the bits used as padding are indeterminate.

When applied to an operand that has struct type, the result is the total number of bytes in a variable of that type, including any padding.

18.6 The fixed statement

In an unsafe context, the embedded-statement (§‎8) production permits an additional construct, the fixed statement, which is used to “fix” a moveable variable such that its address remains constant for the duration of the statement.

embedded-statement: ... fixed-statement

fixed-statement: fixed   (   pointer-type   fixed-pointer-declarators   )   embedded-statement

fixed-pointer-declarators: fixed-pointer-declarator fixed-pointer-declarators   ,   fixed-pointer-declarator

fixed-pointer-declarator: identifier   =   fixed-pointer-initializer

fixed-pointer-initializer: &   variable-reference expression

Each fixed-pointer-declarator declares a local variable of the given pointer-type and initializes that local variable with the address computed by the corresponding fixed-pointer-initializer. A local variable declared in a fixed statement is accessible in any fixed-pointer-initializers occurring to the right of that variable’s declaration, and in the embedded-statement of the fixed statement. A local variable declared by a fixed statement is considered read-only. A compile-time error occurs if the embedded statement attempts to modify this local variable (via assignment or the ++ and ‑‑ operators) or pass it as a ref or out parameter.

A fixed-pointer-initializer can be one of the following:

Copyright Microsoft Corporation 1999-2003. All Rights Reserved.327

Document info
Document views861
Page views861
Page last viewedMon Dec 05 10:48:49 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments