Muokkaa

Jaa


Compiler errors C2500 Through C2599

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 C2500 'identifier1': 'identifier2' is already a direct base class
Compiler error C2501 'identifier': '__declspec(specifier)' can only be applied to structs, unions, classes, or unsigned bit field members
Compiler error C2502 'identifier': too many access modifiers on the base class
Compiler error C2503 'class': base classes cannot contain zero-sized arrays
Compiler error C2504 'class': base class undefined
Compiler error C2505 'symbol': '__declspec(specifier)' can only be applied to declarations or definitions of global objects or static data members
Compiler error C2506 'member': '__declspec(specifier)' cannot be applied to this symbol
Compiler error C2507 'identifier': too many virtual modifiers on the base class
Compiler error C2508 'identifier': '__declspec(specifier1)' cannot be combined with '__declspec(specifier2)'
Compiler error C2509 'identifier': member function not declared in 'class'
Compiler error C2510 'identifier': left of '::' must be a class/struct/union
Compiler error C2511 'identifier': overloaded member function not found in 'class'
Compiler error C2512 'identifier': no appropriate default constructor available
Compiler error C2513 '*type': no variable declared before '='
Compiler error C2514 'class': class has no constructors
Compiler error C2515 'identifier': 'vtguard' can only be applied to class declarations or definitions
Compiler error C2516 'class': is not a legal base class
Compiler error C2517 'identifier': right of '::' is undefined
Compiler error C2518 keyword 'keyword' illegal in base class list; ignored
Compiler error C2519 'identifier': WinRT attributes may only contain public fields
Compiler error C2520 'class': no non-explicit constructor available for implicit conversion
Compiler error C2521 a destructor/finalizer does not take any arguments
Compiler error C2522 'identifier': Overload identifier cannot be used on 'identifier1' as it's already specified on 'identifier2'
Compiler error C2523 'class::~identifier': destructor/finalizer tag mismatch
Compiler error C2524 'identifier': a destructor/finalizer must have a 'void' parameter list
Compiler error C2525 'identifier': The parameter 'identifier1' is named 'identifier2' on the base function and must be matched in a published implementation
Compiler error C2526 'identifier1': C linkage function cannot return C++ class 'identifier2'
Compiler error C2527 'identifier': DefaultOverload cannot be specified on both 'function1' and 'function2'. Remove one specification or rename the function during implementation
Compiler error C2528 'identifier': pointer to reference is illegal
Compiler error C2529 'identifier': reference to reference is illegal
Compiler error C2530 'identifier': references must be initialized
Compiler error C2531 'identifier': reference to a bit field illegal
Compiler error C2532 'identifier': illegal modifier for reference
Compiler error C2533 'identifier': constructors not allowed a return type
Compiler error C2534 'identifier': constructor cannot return a value
Compiler error C2535 'identifier': member function already defined or declared
Compiler error C2536 Obsolete.
Compiler error C2537 'specifier': illegal linkage specification
Compiler error C2538 Obsolete.
Compiler error C2539 Obsolete.
Compiler error C2540 non-constant expression as array bound
Compiler error C2541 'identifier': cannot delete objects that are not pointers
Compiler error C2542 'identifier': class object has no constructor for initialization
Compiler error C2543 expected ']' for operator '[]'
Compiler error C2544 expected ')' for operator '()'
Compiler error C2545 'operator': unable to find overloaded operator
Compiler error C2546 'identifier': when a type is defined in both a PIA and a no-PIA the PIA must be referenced first
Compiler error C2547 'identifier': All parameters of a published method must be explicitly named on the declaration
Compiler error C2548 'function': missing default parameter for parameter parameter
Compiler error C2549 user-defined conversion cannot specify a return type
Compiler error C2550 'identifier': constructor initializer lists are only allowed on constructor definitions
Compiler error C2551 'void *' type needs explicit cast
Compiler error C2552 'identifier': non-aggregates cannot be initialized with an initializer list
Compiler error C2553 'type derived_class::function': overriding virtual function return type differs from 'type base_class::function'
Compiler error C2555 'derived_class::function': overriding virtual function return type differs and is not covariant from 'base_class::function'
Compiler error C2556 'type1 class::function': overloaded function differs only by return type from 'type2 class::function'
Compiler error C2557 'identifier': private and protected members cannot be initialized without a constructor
Compiler error C2558 class 'class': no copy constructor available or copy constructor is declared 'explicit'
Compiler error C2559 'identifier': cannot overload a member function without ref-qualifier with a member function with ref-qualifier
Compiler error C2560 'identifier': cannot overload a member function with ref-qualifier with a member function without ref-qualifier
Compiler error C2561 'function': function must return a value
Compiler error C2562 'function': 'void' function returning a value
Compiler error C2563 mismatch in formal parameter list
Compiler error C2564 Obsolete.
Compiler error C2565 'identifier': ref-qualifier is illegal for constructors/destructors
Compiler error C2566 overloaded function in conditional expression
Compiler error C2567 unable to open metadata in 'filename', possible_reason
Compiler error C2568 'identifier': unable to resolve function overload
Compiler error C2569 'identifier': enum/union cannot be used as a base class
Compiler error C2570 'identifier': union cannot have base classes
Compiler error C2571 'identifier': virtual function cannot be in union 'union'
Compiler error C2572 'function': redefinition of default argument: parameter number
Compiler error C2573 'class': cannot delete pointers to objects of this type; the class has no non-placement overload for 'operator delete'. Use ::delete, or add 'operator delete(void*)' to the class
Compiler error C2574 'destructor': cannot be declared static
Compiler error C2575 'identifier': only member functions and bases can be virtual
Compiler error C2576 'identifier': cannot introduce a new virtual method as 'public'. Consider making the method non-virtual, or change the accessibility to 'internal' or 'protected private'
Compiler error C2577 'identifier': a destructor/finalizer cannot have a return type
Compiler error C2578 'class': type cannot have a 'protected' or 'protected public' constructor
Compiler error C2579 unable to resolve type type (offset). It is expected in filename
Compiler error C2580 'identifier': multiple versions of a defaulted special member functions are not allowed
Compiler error C2581 'type': static 'operator =' function is illegal
Compiler error C2582 'operator operator' function is unavailable in 'type'
Compiler error C2583 'identifier': 'const/volatile' 'this' pointer is illegal for constructors/destructors
Compiler error C2584 'class': direct base 'base_class2' is inaccessible; already a base of 'base_class1'
Compiler error C2585 explicit conversion to 'type' is ambiguous
Compiler error C2586 incorrect user-defined conversion syntax: illegal indirections
Compiler error C2587 'identifier': illegal use of local variable as default parameter
Compiler error C2588 '::~identifier': illegal global destructor/finalizer
Compiler error C2589 'identifier': illegal token on right side of '::'
Compiler error C2590 'identifier': only a constructor can have a base/member initializer list
Compiler error C2591 ExclusiveTo cannot use 'type' as an argument. Only a 'ref class' is a valid argument
Compiler error C2592 'class': 'base_class2' is inherited from 'base_class1' and cannot be re-specified
Compiler error C2593 'operator identifier' is ambiguous
Compiler error C2594 'operator': ambiguous conversions from 'type1' to 'type2'
Compiler error C2595 'identifier' A WinRT attribute type must be sealed
Compiler error C2596 'identifier' A WinRT attribute field can only be a 'public enum class', 'int', 'unsigned int', 'bool', 'Platform::Type', 'Platform::String' or 'Windows::Foundation::HResult'
Compiler error C2597 illegal reference to non-static member 'identifier'
Compiler error C2598 linkage specification must be at global scope
Compiler error C2599 'identifier': the forward declaration of a managed/WinRT enum is not allowed

See also

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