Skip to content

Commit d13e272

Browse files
Merge pull request #5658 from Rageking8/improve-c2135-error-reference
Improve C2135 error reference
2 parents 9acdb7b + 797e67b commit d13e272

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
---
22
title: "Compiler Error C2135"
33
description: "Learn more about: Compiler Error C2135"
4-
ms.date: 11/04/2016
4+
ms.date: 08/13/2025
55
f1_keywords: ["C2135"]
66
helpviewer_keywords: ["C2135"]
77
---
88
# Compiler Error C2135
99

10-
> 'bit operator' : illegal bit field operation
10+
> '*identifier*': you cannot apply '*operator*' to a bit-field
1111
1212
## Remarks
1313

14-
The address-of operator (`&`) cannot be applied to a bit field.
14+
The [address-of operator (`&`)](../../cpp/address-of-operator-amp.md), [unary plus operator (`+`)](../../cpp/unary-plus-and-negation-operators-plus-and.md), [unary negation operator (`-`)](../../cpp/unary-plus-and-negation-operators-plus-and.md), [logical negation operator (`!`)](../../cpp/logical-negation-operator-exclpt.md), [one's complement operator (`~`)](../../cpp/one-s-complement-operator-tilde.md), and [indirection operator (`*`)](../../cpp/indirection-operator-star.md) cannot be applied to a bit-field in this context.
1515

1616
## Example
1717

1818
The following example generates C2135:
1919

2020
```cpp
2121
// C2135.cpp
22-
struct S {
23-
int i : 1;
24-
};
2522

26-
struct T {
27-
int j;
23+
struct S
24+
{
25+
int bit_field : 1;
26+
int integer;
2827
};
29-
int main() {
30-
&S::i; // C2135 address of a bit field
31-
&T::j; // OK
28+
29+
int main()
30+
{
31+
&S::bit_field; // C2135
32+
&S::integer; // OK
3233
}
3334
```
35+
36+
## See also
37+
38+
[C2104](compiler-error-c2104.md)

0 commit comments

Comments
 (0)