Muokkaa

Jaa


Compiler errors C2800 Through C2899

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 C2800 'operator operator' cannot be overloaded
Compiler error C2801 'member' must be a non-static member
Compiler error C2802 static member 'operator operator' has no formal parameters
Compiler error C2803 'operator operator' must have at least one formal parameter of class type
Compiler error C2804 binary 'operator operator' has too many parameters
Compiler error C2805 binary 'operator operator' has too few parameters
Compiler error C2806 'operator operator' has too many formal parameters
Compiler error C2807 the second formal parameter to postfix 'operator operator' must be 'int'
Compiler error C2808 unary 'operator operator' has too many formal parameters
Compiler error C2809 'operator operator' has no formal parameters
Compiler error C2810 'interface': an interface can only inherit from another interface
Compiler error C2811 'type1': cannot inherit from 'type2', a ref class can only inherit from a ref class or interface class
Compiler error C2812 #import is not supported with /clr:pure and /clr:safe
Compiler error C2813 #import is not supported with /MP
Compiler error C2814 'member': a native type cannot be nested within a managed/WinRT type 'class'
Compiler error C2815 'operator delete': first formal parameter must be 'void *', but 'type' was used
Compiler error C2816 invocation of function-like macro 'identifier' is missing terminating ')'
Compiler error C2817 return type for 'operator delete' must be 'void'
Compiler error C2818 application of overloaded 'operator ->' is recursive through type 'class'
Compiler error C2819 type 'class' does not have an overloaded member 'operator ->'
Compiler error C2820 Obsolete.
Compiler error C2821 first formal parameter to 'operator new' must be 'size_t'
Compiler error C2822 local unwind is not supported on this platform
Compiler error C2823 a typedef template/generic is illegal
Compiler error C2824 return type for 'operator new' must be 'void *'
Compiler error C2825 'identifier': must be a class or namespace when followed by '::'
Compiler error C2826 Obsolete.
Compiler error C2827 'operator operator' cannot be globally overridden with unary form
Compiler error C2828 'operator operator' cannot be globally overridden with binary form
Compiler error C2829 'operator operator' cannot have a variable parameter list
Compiler error C2830 only placement parameters to 'operator new' can have default values
Compiler error C2831 'operator operator' cannot have default parameters
Compiler error C2832 'identifier': a reference type cannot be value-initialized
Compiler error C2833 'operator token' is not a recognized operator or type
Compiler error C2834 'operator operator' must be globally qualified (Obsolete in Visual Studio 2022.)
Compiler error C2835 user-defined conversion 'type' takes no formal parameters
Compiler error C2836 'identifier': only one non-static data member of a union may have a default member initializer
Compiler error C2837 'function': cannot use OpenMP directives and #pragma loop(hint_parallel) in same function
Compiler error C2838 'identifier': illegal qualified name in member declaration
Compiler error C2839 invalid return type 'type' for overloaded 'operator ->'
Compiler error C2840 instruction word argument not constant
Compiler error C2841 register argument not constant
Compiler error C2842 'class': a managed/WinRT type may not define its own 'operator new' or 'operator delete'
Compiler error C2843 'member': cannot take the address of a non-static data member or method of a managed/WinRT type
Compiler error C2844 'identifier': cannot be a member of interface 'interface'
Compiler error C2845 'type': pointer arithmetic not allowed on this type
Compiler error C2846 'interface': an interface cannot have a constructor
Compiler error C2847 cannot apply sizeof to managed/WinRT type 'class'
Compiler error C2848 'class': a managed/WinRT type cannot be a member of a union
Compiler error C2849 'interface': an interface cannot have a destructor
Compiler error C2850 'construct': only allowed at file scope; may not be in a nested construct
Compiler error C2851 'enum': A public WinRT enum can only use 'int' or 'unsigned int' as a base type
Compiler error C2852 'identifier': only data members can be initialized within a class
Compiler error C2853 'identifier': a non-static data member cannot have a type that contains 'auto'
Compiler error C2854 syntax error in #pragma hdrstop
Compiler error C2855 command-line option 'option' inconsistent with precompiled header
Compiler error C2856 #pragma hdrstop cannot be inside an #if block
Compiler error C2857 '#include' statement specified with the /Ycfilename command-line option was not found in the source file
Compiler error C2858 command-line option '/Yc (/Fdfilename)' inconsistent with precompiled header, which used '/Fdfilename' (Obsolete in Visual Studio 2022.)
Compiler error C2859 filename is not the filetype file that was used when this precompiled header was created, recreate the precompiled header.
Compiler error C2860 'void' cannot be used as a function parameter except for '(void)'
Compiler error C2861 'declaration': an interface member function cannot be defined
Compiler error C2862 'interface': an interface can only have public members
Compiler error C2863 'interface': an interface cannot have friends
Compiler error C2864 'identifier': a static data member/template variable with an in-class initializer must have non-volatile const integral type
Compiler error C2865 'operator': illegal comparison for object pointer/handle
Compiler error C2866 Obsolete.
Compiler error C2867 'identifier': is not a namespace
Compiler error C2868 'identifier': illegal syntax for using-declaration; expected qualified-name
Compiler error C2869 'identifier': has already been defined to be a namespace
Compiler error C2870 'identifier': a namespace definition must appear either at file scope or immediately within another namespace definition
Compiler error C2871 'identifier': a namespace with this name does not exist
Compiler error C2872 'identifier': ambiguous symbol
Compiler error C2873 'symbol': symbol cannot be used in a using-declaration
Compiler error C2874 using-declaration causes a multiple declaration of 'identifier'
Compiler error C2875 using-declaration causes a multiple declaration of 'class::identifier' (Obsolete in Visual Studio 2022.)
Compiler error C2876 'class::member': not all overloads are accessible
Compiler error C2877 'member' is not accessible from 'class'
Compiler error C2878 'identifier': a namespace or class of this name does not exist
Compiler error C2879 'identifier': only an existing namespace can be given an alternative name by a namespace alias definition
Compiler error C2880 __swi or __hvc requires a valid constant as first argument (SWI number)
Compiler error C2881 'identifier': is already used as an alias for 'class'
Compiler error C2882 'identifier': illegal use of namespace identifier in expression
Compiler error C2883 'function': function declaration conflicts with 'identifier' introduced by using-declaration
Compiler error C2884 'identifier': introduced by using-declaration conflicts with local function 'function'
Compiler error C2885 'class::identifier': not a valid using-declaration at non-class scope
Compiler error C2886 'class::identifier': symbol cannot be used in a member using-declaration
Compiler error C2887 __swi or __hvc cannot have more than five arguments (SWI number, r0 - r3)
Compiler error C2888 'identifier': symbol cannot be defined within namespace 'namespace'
Compiler error C2889 'class': a managed/WinRT class type cannot be a virtual base class
Compiler error C2890 'class': a ref class can only have one non-interface base class
Compiler error C2891 'parameter': cannot take the address of a template parameter
Compiler error C2892 local class shall not have member templates
Compiler error C2893 Failed to specialize function template 'template'
Compiler error C2894 templates cannot be declared to have 'C' linkage
Compiler error C2895 'declaration': cannot explicitly instantiate a function template that has been declared with dllimport
Compiler error C2896 'function1': cannot use function template/generic 'function2' as a function argument (Obsolete in Visual Studio 2022.)
Compiler error C2897 a destructor/finalizer cannot be a function template
Compiler error C2898 'declaration': member function templates cannot be virtual
Compiler error C2899 Obsolete.

See also

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