diff --git a/docs/error-messages/compiler-errors-1/compiler-error-c2154.md b/docs/error-messages/compiler-errors-1/compiler-error-c2154.md index 021703b64e..38192df4ca 100644 --- a/docs/error-messages/compiler-errors-1/compiler-error-c2154.md +++ b/docs/error-messages/compiler-errors-1/compiler-error-c2154.md @@ -1,16 +1,36 @@ --- title: "Compiler Error C2154" description: "Learn more about: Compiler Error C2154" -ms.date: 11/04/2016 +ms.date: 09/21/2025 f1_keywords: ["C2154"] helpviewer_keywords: ["C2154"] --- # Compiler Error C2154 -> 'type' : only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type' +> '*type*': only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type' ## Remarks -You can only get the underlying type of an enumeration type. +You can only get the underlying type of an [enumeration](../../cpp/enumerations-cpp.md) type. -For more information, see [Compiler Support for Type Traits](../../extensions/compiler-support-for-type-traits-cpp-component-extensions.md). +## Example + +The following example generates C2154: + +```cpp +// C2154.cpp +// compile with: /c + +struct S {}; +enum E {}; +enum class EC {}; + +__underlying_type(S) s; // C2154 +__underlying_type(int) i; // C2154 +__underlying_type(E) e; // OK +__underlying_type(EC) ec; // OK +``` + +## See also + +[`underlying_type` class](../../standard-library/underlying-type-class.md) diff --git a/docs/error-messages/compiler-errors-1/compiler-errors-c2100-through-c2199.md b/docs/error-messages/compiler-errors-1/compiler-errors-c2100-through-c2199.md index ef2e8e4b3f..676b397bbb 100644 --- a/docs/error-messages/compiler-errors-1/compiler-errors-c2100-through-c2199.md +++ b/docs/error-messages/compiler-errors-1/compiler-errors-c2100-through-c2199.md @@ -69,7 +69,7 @@ The articles in this section of the documentation explain a subset of the error |[Compiler error C2151](compiler-error-c2151.md)|more than one language attribute| |[Compiler error C2152](compiler-error-c2152.md)|'*identifier*': pointers to functions with different attributes| |[Compiler error C2153](compiler-error-c2153.md)|integer literals must have at least one digit| -|[Compiler error C2154](compiler-error-c2154.md)|'*type*': only enumeration type is allowed as an argument to compiler intrinsic type trait '*trait*'| +|[Compiler error C2154](compiler-error-c2154.md)|'*type*': only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type'| |[Compiler error C2155](compiler-error-c2155.md)|'?': invalid left operand, expected arithmetic or pointer type| |[Compiler error C2156](compiler-error-c2156.md)|pragma must be outside function| |[Compiler error C2157](compiler-error-c2157.md)|'*identifier*': must be declared before use in pragma list|