Reputation: 42260
I am working on porting some interop code from the DWM Api in C++ to C#. The DWMWINDOWATTRIBUTE enum only explicitly defines, one value, and I want to know if the remaining values (commented) are correct?
typedef enum _DWMWINDOWATTRIBUTE {
DWMWA_NCRENDERING_ENABLED = 1,
DWMWA_NCRENDERING_POLICY, // 2
DWMWA_TRANSITIONS_FORCEDISABLED, // 3
DWMWA_ALLOW_NCPAINT, // 4
DWMWA_CAPTION_BUTTON_BOUNDS, // 5
DWMWA_NONCLIENT_RTL_LAYOUT, // 6
DWMWA_FORCE_ICONIC_REPRESENTATION, // 7
DWMWA_FLIP3D_POLICY, // 8
DWMWA_EXTENDED_FRAME_BOUNDS, // 9
DWMWA_HAS_ICONIC_BITMAP, // 10
DWMWA_DISALLOW_PEEK, // 11
DWMWA_EXCLUDED_FROM_PEEK, // 12
DWMWA_CLOAK, // 13
DWMWA_CLOAKED, // 14
DWMWA_FREEZE_REPRESENTATION, // 15
DWMWA_LAST // 16
} DWMWINDOWATTRIBUTE;
Upvotes: 1
Views: 1239
Reputation: 227410
Yes, in the C++03 and C++11 standards, 7.2 Enumeration declarations [dcl.enum]:
...An enumerator-definition without an initializer gives the enumerator the value obtained by increasing the value of the previous enumerator by one.
Also note that, in the absence of an initializer, the first enum value is 0
. From the same section:
If the first enumerator has no initializer, the value of the corresponding constant is zero.
Upvotes: 5
Reputation: 1145
Yes that is correct, if you provide a value for the first entry then all the next entries are obtained by increasing the value of the prev enum by 1.
In this case, since you gave the first enum entry a value the next entries are 2,3,4,... respectively.
If you don't provide it, then it starts with a 0 (by default)
Upvotes: 1
Reputation: 2019
Yes enum values are incremented automatically. In C# you can also use the same syntax
public enum _DWMWINDOWATTRIBUTE { DWMWA_NCRENDERING_ENABLED = 1,...}
Upvotes: 1