diff --git a/docs/error-messages/compiler-errors-1/compiler-error-c2135.md b/docs/error-messages/compiler-errors-1/compiler-error-c2135.md index 4af1d4f1b4..aff3621ccb 100644 --- a/docs/error-messages/compiler-errors-1/compiler-error-c2135.md +++ b/docs/error-messages/compiler-errors-1/compiler-error-c2135.md @@ -1,17 +1,17 @@ --- title: "Compiler Error C2135" description: "Learn more about: Compiler Error C2135" -ms.date: 11/04/2016 +ms.date: 08/13/2025 f1_keywords: ["C2135"] helpviewer_keywords: ["C2135"] --- # Compiler Error C2135 -> 'bit operator' : illegal bit field operation +> '*identifier*': you cannot apply '*operator*' to a bit-field ## Remarks -The address-of operator (`&`) cannot be applied to a bit field. +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. ## Example @@ -19,15 +19,20 @@ The following example generates C2135: ```cpp // C2135.cpp -struct S { - int i : 1; -}; -struct T { - int j; +struct S +{ + int bit_field : 1; + int integer; }; -int main() { - &S::i; // C2135 address of a bit field - &T::j; // OK + +int main() +{ + &S::bit_field; // C2135 + &S::integer; // OK } ``` + +## See also + +[C2104](compiler-error-c2104.md)