Difficulty: Easy
Correct Answer: Error: Bit field too large
Explanation:
Introduction / Context:
Bit-field widths cannot exceed the number of bits available in the underlying type. On a 16-bit platform, the width of int is typically 16 bits. Requesting 40 bits is not representable and must be rejected by the compiler.
Given Data / Assumptions:
Concept / Approach:
For a bit-field of type int, the maximum width is the number of value bits that type can store (implementation-defined but generally the bit width of int). If the requested width exceeds that, it is ill-formed or at least a constraint violation for that target.
Step-by-Step Solution:
Verification / Alternative check:
Changing to unsigned int i:15; compiles. Using a wider implementation type (e.g., long) on wider platforms may also work, but not 40 bits on a 16-bit int.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming bit-field widths are portable across platforms; forgetting the underlying type's width limits.
Final Answer:
Error: Bit field too large
Discussion & Comments