Article ID: 47693 - Last Review: July 5, 2005 - Revision: 2.1 INFO: Initializing Unions Initializes First Member of the UnionThis article was previously published under Q47693 On This PageSUMMARY
When initializing a union, the initialization value is applied to the first
member of the union even if the type of the value matches a subsequent
member. As stated in the ANSI Standard, Section 3.5.7:
MORE INFORMATION
The following example demonstrates the issue:
Sample Codetest.a = 3, test.b = 0.00000 test.a = 26214, test.b = 3.600000 test.a = 1080452710, test.b = 3.600000 REFERENCES
For examples and explanation of possible compiler errors and warnings
generated when attempting to initialize a non-primary union element, please
see the following article in the Microsoft Knowledge Base:
39910
(http://support.microsoft.com/kb/39910/EN-US/
)
PRB: Initializing Non-Primary Union Element Produces Errors
APPLIES TO
| Article Translations
|
Back to the top
