cpp-docs
cpp-docs copied to clipboard
Augment C2033 error reference
- Update error message
- Add new "array of bit fields" scenario as seen on various Stack Overflow questions ([1] [2] [3])
- Augment the remarks and overhaul the example
- Add C2531 "See also" link as C2531 is emitted alongside the "reference to bit field" example
Example
// C2033.cpp
// compile with: /c
struct S
{
int* ptr : 1; // C2033
int& ref : 1; // C2033
int arr[3] : 1; // C2033
};
C:\Test>cl /c C2033.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35215 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
C2033.cpp
C2033.cpp(6): error C2033: 'S::ptr': bit field cannot have indirection
C2033.cpp(7): error C2531: 'S::ref': you cannot bind a reference to a bit-field
C2033.cpp(7): error C2033: 'S::ref': bit field cannot have indirection
C2033.cpp(8): error C2033: 'S::arr': bit field cannot have indirection