Redigera

Dela via


Compiler errors C2900 Through C2999

The articles in this section of the documentation explain a subset of the error messages that are generated by the compiler.

Important

The Visual Studio compilers and build tools can report many kinds of errors and warnings. After an error or warning is found, the build tools may make assumptions about code intent and attempt to continue, so that more issues can be reported at the same time. If the tools make the wrong assumption, later errors or warnings may not apply to your project. When you correct issues in your project, always start with the first error or warning that's reported, and rebuild often. One fix may make many subsequent errors go away.

To get help on a particular diagnostic message in Visual Studio, select it in the Output window and press the F1 key. Visual Studio opens the documentation page for that error, if one exists. You can also use the search tool at the top of the page to find articles about specific errors or warnings. Or, browse the list of errors and warnings by tool and type in the table of contents on this page.

Note

Not every Visual Studio error or warning is documented. In many cases, the diagnostic message provides all of the information that's available. If you landed on this page when you used F1 and you think the error or warning message needs additional explanation, let us know. You can use the feedback buttons on this page to raise a documentation issue on GitHub. If you think the error or warning is wrong, or you've found another problem with the toolset, report a product issue on the Developer Community site. You can also send feedback and enter bugs within the IDE. In Visual Studio, go to the menu bar and choose Help > Send Feedback > Report a Problem, or submit a suggestion by using Help > Send Feedback > Send a Suggestion. Some compiler error topics were created that are not emitted by the compiler and now redirect to this page instead.

You may find additional assistance for errors and warnings in Microsoft Learn Q&A forums. Or, search for the error or warning number on the Visual Studio C++ Developer Community site. You can also search Stack Overflow to find solutions.

For links to additional help and community resources, see Visual C++ Help and Community.

Error messages

Error Message
Compiler error C2900 'declarator': member function templates in WinRT classes must be 'private', 'internal' or 'protected private'
Compiler error C2901 'identifier': A generic interface or delegate cannot be public
Compiler error C2902 'token': unexpected token following 'template/generic', identifier expected (Obsolete in Visual Studio 2022.)
Compiler error C2903 'identifier': symbol is neither a class template/generic nor a function template/generic
Compiler error C2904 'identifier': name already used for a template in the current scope
Compiler error C2905 Obsolete.
Compiler error C2906 'template': explicit specialization requires 'template <>'
Compiler error C2907 register argument 'number' does not specify a valid register number
Compiler error C2908 explicit specialization; 'template' has already been instantiated
Compiler error C2909 'identifier': explicit instantiation of function template requires return type
Compiler error C2910 'function': cannot be explicitly specialized
Compiler error C2911 'member': cannot be declared or defined in the current scope
Compiler error C2912 explicit specialization 'declaration' is not a specialization of a function template
Compiler error C2913 explicit specialization; 'declaration' is not a specialization of a class template
Compiler error C2914 'identifier': cannot deduce template/generic argument as function argument is ambiguous
Compiler error C2915 'identifier': 'type' cannot be directly used on the published surface of a WinRT type. Use 'Platform::Object^' instead to pass this type
Compiler error C2916 'identifier': [FlagsAttribute] must (only) be specified on a public enum with an 'unsigned int' underlying type
Compiler error C2917 'identifier': invalid template-parameter (Obsolete in Visual Studio 2022.)
Compiler error C2918 'identifier': Indexed properties cannot be used on the published surface of a WinRT type
Compiler error C2919 'type': Operators cannot be used on the published surface of a WinRT type
Compiler error C2920 redefinition: 'type': class template/generic has already been declared as 'declaration'
Compiler error C2921 redefinition: 'type': class template/generic is being redeclared as 'declaration'
Compiler error C2922 'interface': A WinRT interface cannot contain static members
Compiler error C2923 'type': 'identifier' is not a valid template/generic type argument for parameter 'parameter'
Compiler error C2924 __declspec(interrupt) routine argument not in R2
Compiler error C2925 __declspec(interrupt) routine cannot use floating-point
Compiler error C2926 'identifier': a default member initializer is not allowed for a member of an anonymous struct within a union
Compiler error C2927 'identifier': a function template must be called with at least one argument
Compiler error C2928 explicit instantiation; 'identifier' is not a function or static data member of template-class 'class'
Compiler error C2929 'declarator': explicit instantiation; cannot explicitly force and suppress instantiation of template-class member
Compiler error C2930 'class': template-id/generic-id redefined as an enumerator of 'enum identifier'
Compiler error C2931 'class1': template-id/generic-id redefined as a member function of 'class2' (Obsolete in Visual Studio 2022.)
Compiler error C2932 'type': template-id/generic-id redefined as a data member of 'identifier' (Obsolete in Visual Studio 2022.)
Compiler error C2933 'type': template-id/generic-id redefined as a typedef member of 'identifier' (Obsolete in Visual Studio 2022.)
Compiler error C2934 'type': template-id/generic-id redefined as a nested 'item' of 'identifier' (Obsolete in Visual Studio 2022.)
Compiler error C2935 'type': template-id/generic-id redefined as a global function (Obsolete in Visual Studio 2022.)
Compiler error C2936 'type': template-id/generic-id redefined as a global data variable (Obsolete in Visual Studio 2022.)
Compiler error C2937 'type': template-id/generic-id redefined as a global typedef (Obsolete in Visual Studio 2022.)
Compiler error C2938 'identifier' : Failed to specialize alias template
Compiler error C2939 'type': template-id/generic-id redefined as a local data variable (Obsolete in Visual Studio 2022.)
Compiler error C2940 'type': template-id/generic-id redefined as a local typedef (Obsolete in Visual Studio 2022.)
Compiler error C2941 'type': template-id/generic-id redefined as a local 'item' (Obsolete in Visual Studio 2022.)
Compiler error C2942 'type': template-id/generic-id redefined as a formal argument of a function (Obsolete in Visual Studio 2022.)
Compiler error C2943 'type': template-id/generic-id redefined as a type argument of a template (Obsolete in Visual Studio 2022.)
Compiler error C2944 'type': template-id/generic-id redefined as a value argument of a template (Obsolete in Visual Studio 2022.)
Compiler error C2945 explicit instantiation does not refer to a template-class specialization
Compiler error C2946 explicit instantiation; 'type' is not a template-class specialization
Compiler error C2947 expecting '>' to terminate template arguments, found 'token'
Compiler error C2948 explicit instantiation; storage class specifier 'specifier' not permitted on specialization
Compiler error C2949 thread_local is not supported with /kernel
Compiler error C2950 Obsolete.
Compiler error C2951 template/generic declarations are only permitted at global, namespace, or class scope
Compiler error C2952 'declaration': template/generic declaration missing template/generic parameter list
Compiler error C2953 'type': class template has already been defined
Compiler error C2954 instruction word argument not in range
Compiler error C2955 'type': use of class template/generic requires template/generic argument list
Compiler error C2956 usual deallocation function 'function' would be chosen as placement deallocation function
Compiler error C2957 'token': invalid left delimiter: expected '<'
Compiler error C2958 the left delimiter found at 'file(line_number)' was not matched correctly
Compiler error C2959 a generic class or function may not be a member of a template
Compiler error C2960 Obsolete.
Compiler error C2961 'function': inconsistent explicit instantiations, a previous explicit instantiation did not specify 'argument'
Compiler error C2962 syntax error: 'token': expected template-class member function definition to end with '}'
Compiler error C2963 Obsolete.
Compiler error C2964 Obsolete.
Compiler error C2965 __declspec(specifier) is not supported with /kernel
Compiler error C2966 'identifier1': must have the same __declspec(code_seg(...)) as its base class 'identifier2' (Obsolete in Visual Studio 2022.)
Compiler error C2967 'identifier': an overriding virtual function must have the same __declspec(code_seg(...)) as an overridden virtual function (Obsolete in Visual Studio 2022.)
Compiler error C2968 'identifier': recursive alias declaration
Compiler error C2969 syntax error: 'token': expected member function definition to end with '}'
Compiler error C2970 'type': template parameter 'parameter': 'argument': an expression involving objects with internal linkage cannot be used as a non-type argument
Compiler error C2971 'type': template parameter 'parameter': 'argument': a variable with non-static storage duration cannot be used as a non-type argument
Compiler error C2972 'type': template parameter 'parameter': the type of non-type argument is invalid
Compiler error C2973 'template': invalid template argument 'number'
Compiler error C2974 'type': invalid template/generic argument for 'parameter', type expected
Compiler error C2975 'type': invalid template argument for 'parameter', expected compile-time constant expression
Compiler error C2976 'type': too few template/generic arguments
Compiler error C2977 'type': too many template/generic arguments
Compiler error C2978 syntax error: expected 'keyword1' or 'keyword2'; found type 'type'; non-type parameters are not supported in generics
Compiler error C2979 explicit specializations are not supported in generics
Compiler error C2980 C++ exception handling is not supported with /kernel
Compiler error C2981 the dynamic form of 'keyword' is not supported with /kernel
Compiler error C2982 'declaration': different __declspec(code_seg(...)) used: was 'identifier1' now 'identifier2'
Compiler error C2983 'declaration': all declarations must have an identical __declspec(code_seg(...))
Compiler error C2984 Obsolete.
Compiler error C2985 'argument': the argument to __declspec(code_seg(...)) must be a text section
Compiler error C2986 'identifier': __declspec(code_seg(...)) can only be applied to a class or a function
Compiler error C2987 a declaration cannot have both __declspec(code_seg('identifier')) and __declspec(code_seg('value'))
Compiler error C2988 unrecognizable template declaration/definition
Compiler error C2989 'class': class template/generic has already been declared as a non-class template/generic
Compiler error C2990 'class': non-class template/generic has already been declared as a class template/generic
Compiler error C2991 redefinition of template/generic parameter 'parameter'
Compiler error C2992 'class': invalid or missing template/generic parameter list
Compiler error C2993 'type': illegal type for non-type template parameter 'identifier'
Compiler error C2994 unnamed class in template parameter list
Compiler error C2995 'declaration': function template has already been defined
Compiler error C2996 'function': recursive function template definition
Compiler error C2997 'function': array bound cannot be deduced from a default member initializer
Compiler error C2998 'declarator': cannot be a template definition

See also

C/C++ Compiler and build tools errors and warnings
Compiler errors C2000 - C3999, C7000 - C7999