Skip to content

Structure error references in range [C2551, C2580] #5603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2551.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2551"
title: "Compiler Error C2551"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2551"
ms.date: 11/04/2016
f1_keywords: ["C2551"]
helpviewer_keywords: ["C2551"]
ms.assetid: 6f48b91d-635b-4eef-b13c-1bf2056c1053
---
# Compiler Error C2551

'void *' type needs explicit cast
> 'void *' type needs explicit cast

## Remarks

A **`void`** pointer is assigned to a nonvoid pointer by implicit conversion. You must use an explicit cast.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2552.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2552"
title: "Compiler Error C2552"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2552"
ms.date: 11/04/2016
f1_keywords: ["C2552"]
helpviewer_keywords: ["C2552"]
ms.assetid: 0e0ab759-788a-4faf-9337-80d4b9e2e8c9
---
# Compiler Error C2552

'identifier' : non-aggregates cannot be initialized with initializer list
> 'identifier' : non-aggregates cannot be initialized with initializer list

## Remarks

The aggregate identifier was incorrectly initialized.

Expand Down Expand Up @@ -42,7 +43,9 @@ The following represent the reasons C2552 may fire when an aggregate initializat

- The type has a non-fixed dimension array (zero-array) whose elements have destructors.

The following sample generates C2552:
## Example

The following example generates C2552:

```cpp
// C2552.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2553.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2553"
title: "Compiler Error C2553"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2553"
ms.date: 11/04/2016
f1_keywords: ["C2553"]
helpviewer_keywords: ["C2553"]
ms.assetid: 64bc1e9a-627f-4ce9-b7bc-dc911bdb9180
---
# Compiler Error C2553

'base_function': overriding virtual function return type differs from 'override_function'
> 'base_function': overriding virtual function return type differs from 'override_function'

## Remarks

A function in a derived class attempted to override a virtual function in a base class, but the derived class function did not have the same return type as the base class function. An override function signature must match the signature of the function being overridden.

The following sample generates C2553:
## Example

The following example generates C2553:

```cpp
// C2553.cpp
Expand Down
9 changes: 4 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2555.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Compiler Error C2555"
description: "Reference for Visual Studio C++ compiler error C2555."
ms.date: "03/30/2020"
ms.date: 03/30/2020
f1_keywords: ["C2555"]
helpviewer_keywords: ["C2555"]
ms.assetid: 5e49ebb8-7c90-457a-aa12-7ca7ab6574b2
---
# Compiler Error C2555

> '*class1*::*function1*': overriding virtual function return type differs and is not covariant from '*class2*::*function2*'

A virtual function and a derived overriding function have identical parameter lists but different return types.

## Remarks

A virtual function and a derived overriding function have identical parameter lists but different return types.

In C++, an overriding function in a derived class can't differ only by return type from a virtual function in a base class.

There's an exception to this rule for certain return types. When a derived class overrides a public base class, it may return a pointer or reference to the derived class instead of a base-class pointer or reference. These return types are called *covariant*, because they vary together with the type. This rule exception doesn't allow covariant reference-to-pointer or pointer-to-pointer types.
Expand All @@ -34,7 +33,7 @@ is
Guid CheckSources(Guid sourceID, Guid carouselIDs[]) [];
```

The following sample generates C2555:
The following example generates C2555:

```cpp
// C2555.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2557.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2557"
title: "Compiler Error C2557"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2557"
ms.date: 11/04/2016
f1_keywords: ["C2557"]
helpviewer_keywords: ["C2557"]
ms.assetid: 48a33d82-aa16-4658-b346-2311fcb39864
---
# Compiler Error C2557

'identifier' : private and protected members cannot be initialized without a constructor
> 'identifier' : private and protected members cannot be initialized without a constructor

## Remarks

Only members and friends can assign a value to a private or protected member. Nonpublic members should be initialized in the class constructor.
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2558.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2558"
title: "Compiler Error C2558"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2558"
ms.date: 11/04/2016
f1_keywords: ["C2558"]
helpviewer_keywords: ["C2558"]
ms.assetid: 822b701e-dcae-423a-b21f-47f36aff9c90
---
# Compiler Error C2558

'identifier' : no copy constructor available or copy constructor is declared 'explicit'
> 'identifier' : no copy constructor available or copy constructor is declared 'explicit'

## Remarks

A copy constructor initializes an object from another object of the same type. (It makes a copy of the object.) The compiler generates a default copy constructor if you do not define any constructors.

Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2561.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2561"
title: "Compiler Error C2561"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2561"
ms.date: 11/04/2016
f1_keywords: ["C2561"]
helpviewer_keywords: ["C2561"]
ms.assetid: 0abe955b-53a6-4a3c-8362-b1a8eb40e8d1
---
# Compiler Error C2561

'identifier' : function must return a value
> 'identifier' : function must return a value

## Remarks

The function was declared as returning a value, but the function definition does not contain a **`return`** statement.

Expand All @@ -20,7 +21,9 @@ This error can be caused by an incorrect function prototype:

1. C++ functions containing inline assembly routines that store the return value in the `AX` register may need a return statement. Copy the value in `AX` to a temporary variable and return that variable from the function.

The following sample generates C2561:
## Example

The following example generates C2561:

```cpp
// C2561.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2562.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
description: "Learn more about: Compiler Error C2562"
title: "Compiler Error C2562"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2562"
ms.date: 11/04/2016
f1_keywords: ["C2562"]
helpviewer_keywords: ["C2562"]
ms.assetid: 2c41e511-9952-4b98-9976-6b1523613e1b
---
# Compiler Error C2562

'identifier' : 'void' function returning a value
> 'identifier' : 'void' function returning a value

## Remarks

The function is declared as **`void`** but returns a value.

This error can be caused by an incorrect function prototype.

This error may be fixed if you specify the return type in the function declaration.

The following sample generates C2562:
## Example

The following example generates C2562:

```cpp
// C2562.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2563.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2563"
title: "Compiler Error C2563"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2563"
ms.date: 11/04/2016
f1_keywords: ["C2563"]
helpviewer_keywords: ["C2563"]
ms.assetid: 54abba68-6458-4ca5-894d-3babdb7b3552
---
# Compiler Error C2563

mismatch in formal parameter list
> mismatch in formal parameter list

## Remarks

The formal parameter list of a function (or a pointer to a function) does not match those of another function (or pointer to a member function). As a result, the assignment of functions or pointers cannot be made.

The following sample generates C2563:
## Example

The following example generates C2563:

```cpp
// C2563.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2566.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2566"
title: "Compiler Error C2566"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2566"
ms.date: 11/04/2016
f1_keywords: ["C2566"]
helpviewer_keywords: ["C2566"]
ms.assetid: 8fe10fb2-d974-432a-a56b-3a61b9a8dfc2
---
# Compiler Error C2566

overloaded function in conditional expression
> overloaded function in conditional expression

## Remarks

An overloaded function in a conditional expression cannot be evaluated.
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2567.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2567"
title: "Compiler Error C2567"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2567"
ms.date: 11/04/2016
f1_keywords: ["C2567"]
helpviewer_keywords: ["C2567"]
ms.assetid: 9c140ac9-7059-47e6-9ba1-e7939c8c0dc3
---
# Compiler Error C2567

unable to open metadata in 'file', file may have been deleted or moved
> unable to open metadata in 'file', file may have been deleted or moved

## Remarks

A metadata file that was referenced in source (with `#using`) was not found in the same directory by the compiler back end process as it was by the compiler front end process. See [#using Directive](../../preprocessor/hash-using-directive-cpp.md) for more information.

Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2568.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2568"
title: "Compiler Error C2568"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2568"
ms.date: 11/04/2016
f1_keywords: ["C2568"]
helpviewer_keywords: ["C2568"]
ms.assetid: 140b4dc9-5a88-4032-9aef-a224bb796f72
---
# Compiler Error C2568

'identifier1' : unable to resolve function overload
> 'identifier1' : unable to resolve function overload

## Remarks

The compiler cannot determine which overloaded function to call. The actual parameters passed to the function must be cast to match the formal parameters for one of the overloaded function, but no one match is unambiguously better than all others.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2569.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2569"
title: "Compiler Error C2569"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2569"
ms.date: 11/04/2016
f1_keywords: ["C2569"]
helpviewer_keywords: ["C2569"]
ms.assetid: 092bed1e-f631-436c-9586-7750629f6fac
---
# Compiler Error C2569

'EnumOrUnion' : enum/union cannot be used as a base class
> 'EnumOrUnion' : enum/union cannot be used as a base class

## Remarks

If you must derive a type from the specified union or enumeration, change the union or enumeration to a class or structure.

The following sample generates C2569:
## Example

The following example generates C2569:

```cpp
// C2569.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2570.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2570"
title: "Compiler Error C2570"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2570"
ms.date: 11/04/2016
f1_keywords: ["C2570"]
helpviewer_keywords: ["C2570"]
ms.assetid: d65d0b32-2fac-464a-bcdf-0ebcedf3bf32
---
# Compiler Error C2570

'identifier' : union cannot have base classes
> 'identifier' : union cannot have base classes

## Remarks

A union derives from a class, structure, or union. This is not allowed. Declare the derived type as a class or structure instead.

The following sample generates C2570:
## Example

The following example generates C2570:

```cpp
// C2570.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2571.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
description: "Learn more about: Compiler Error C2571"
title: "Compiler Error C2571"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2571"
ms.date: 11/04/2016
f1_keywords: ["C2571"]
helpviewer_keywords: ["C2571"]
ms.assetid: c6522616-dee9-4d7d-9bf8-30a7e1deaadf
---
# Compiler Error C2571

'function' : virtual function cannot be in union 'union'
> 'function' : virtual function cannot be in union 'union'

## Remarks

A union is declared with a virtual function. You can declare a virtual function only in a class or structure. Possible resolutions:

1. Change the union to a class or structure.

1. Make the function nonvirtual.

The following sample generates C2571:
## Example

The following example generates C2571:

```cpp
// C2571.cpp
Expand Down
Loading