Skip to content

Structure error references in range [C2651, C2670] #5617

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-c2651.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2651"
title: "Compiler Error C2651"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2651"
ms.date: 11/04/2016
f1_keywords: ["C2651"]
helpviewer_keywords: ["C2651"]
ms.assetid: c3524a89-47d1-43f6-9e20-2cda15f9ae8a
---
# Compiler Error C2651

'data type' : left of 'operator' must be a class, struct or union
> 'data type' : left of 'operator' must be a class, struct or union

## Remarks

To use a template parameter as if it is a class, specialize the class template with a class instead of an integral type.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2652.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2652"
title: "Compiler Error C2652"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2652"
ms.date: 11/04/2016
f1_keywords: ["C2652"]
helpviewer_keywords: ["C2652"]
ms.assetid: 6e3d1a90-a989-4088-8afd-dc82f6a2d66f
---
# Compiler Error C2652

'identifier' : illegal copy constructor: first parameter must not be an 'identifier'
> 'identifier' : illegal copy constructor: first parameter must not be an 'identifier'

## Remarks

The first parameter in the copy constructor has the same type as the class, structure, or union for which it is defined. The first parameter can be a reference to the type but not the type itself.

The following sample generates C2651:
## Example

The following example generates C2651:

```cpp
// C2652.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["C2653"]

> '*identifier*' : is not a class or namespace name

## Remarks

The language syntax requires a class, structure, union, or namespace name here.

This error can occur when you use a name that has not been declared as a class, structure, union, or namespace in front of a scope operator. To fix this issue, declare the name or include the header that declares the name before it is used.
Expand All @@ -17,7 +19,7 @@ C2653 is also possible if you try to define a *compound namespace*, a namespace

## Examples

This sample generates C2653 because a scope name is used but not declared. The compiler expects a class, structure, union, or namespace name before a scope operator (::).
This example generates C2653 because a scope name is used but not declared. The compiler expects a class, structure, union, or namespace name before a scope operator (::).

```cpp
// C2653.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2654.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2654"
title: "Compiler Error C2654"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2654"
ms.date: 11/04/2016
f1_keywords: ["C2654"]
helpviewer_keywords: ["C2654"]
ms.assetid: ca7de1bd-576b-40bf-96fc-a91984827d20
---
# Compiler Error C2654

'identifier' : attempt to access member outside a member function
> 'identifier' : attempt to access member outside a member function

## Remarks

A member is accessed in a declaration. Member data can be accessed only in member functions.

Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2655.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2655"
title: "Compiler Error C2655"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2655"
ms.date: 11/04/2016
f1_keywords: ["C2655"]
helpviewer_keywords: ["C2655"]
ms.assetid: beaefa6e-51b3-4df9-9150-960f3fbf40e0
---
# Compiler Error C2655

'identifier' : definition or redeclaration illegal in current scope
> 'identifier' : definition or redeclaration illegal in current scope

## Remarks

An identifier can be redeclared only at global scope.

The following sample generates C2655:
## Example

The following example generates C2655:

```cpp
// C2655.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2656.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2656"
title: "Compiler Error C2656"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2656"
ms.date: 11/04/2016
f1_keywords: ["C2656"]
helpviewer_keywords: ["C2656"]
ms.assetid: 1ec91186-0735-4904-859b-59da9af2d426
---
# Compiler Error C2656

'function' : function not allowed as a bit field
> 'function' : function not allowed as a bit field

## Remarks

A function is declared as a member of a bit field.

Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2657.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2657"
title: "Compiler Error C2657"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2657"
ms.date: 11/04/2016
f1_keywords: ["C2657"]
helpviewer_keywords: ["C2657"]
ms.assetid: f7cf29a9-684a-4605-9469-ecfee9ba4b03
---
# Compiler Error C2657

'class::*' found at the start of a statement (did you forget to specify a type?)
> 'class::*' found at the start of a statement (did you forget to specify a type?)

## Remarks

The line began with a pointer-to-member identifier.

This error can be caused by a missing type specifier in the declaration of a pointer to a member.

The following sample generates C2657:
## Example

The following example generates C2657:

```cpp
// C2657.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2658.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2658"
title: "Compiler Error C2658"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2658"
ms.date: 11/04/2016
f1_keywords: ["C2658"]
helpviewer_keywords: ["C2658"]
ms.assetid: 638368e8-7893-4a14-abec-13c768a9543a
---
# Compiler Error C2658

'member': redefinition in anonymous struct/union
> 'member': redefinition in anonymous struct/union

## Remarks

Two anonymous structures or unions contained member declarations with the same identifier but with different types. Under [/Za](../../build/reference/za-ze-disable-language-extensions.md), you will also get this error for members with the same identifier and type.

The following sample generates C2658:
## Example

The following example generates C2658:

```cpp
// C2658.cpp
Expand Down
15 changes: 10 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2659.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
---
description: "Learn more about: Compiler Error C2659"
title: "Compiler Error C2659"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2659"
ms.date: 11/04/2016
f1_keywords: ["C2659"]
helpviewer_keywords: ["C2659"]
ms.assetid: b0883600-4d27-4ca7-a931-8ca6bd48654d
---
# Compiler Error C2659

'operator' : function as left operand
> 'operator' : function as left operand

## Remarks

A function was on the left side of the specified operator. The most common reason for this error is that the compiler has parsed the identifier on the left side of the operator as a function when the developer intended it to be a variable. For more information, see Wikipedia article [Most vexing parse](https://en.wikipedia.org/wiki/Most_vexing_parse).

## Examples

A function was on the left side of the specified operator. The most common reason for this error is that the compiler has parsed the identifier on the left side of the operator as a function when the developer intended it to be a variable. For more information, see Wikipedia article [Most vexing parse](https://en.wikipedia.org/wiki/Most_vexing_parse). This example shows a function declaration and a variable definition that are easily confused:
This example shows a function declaration and a variable definition that are easily confused:

```cpp
// C2659a.cpp
Expand Down
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c2660.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2660"
title: "Compiler Error C2660"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2660"
ms.date: 11/04/2016
f1_keywords: ["C2660"]
helpviewer_keywords: ["C2660"]
ms.assetid: 2e01a1db-4f00-4df6-a04d-cb6f70a6922b
---
# Compiler Error C2660

'function' : function does not take number parameters
> 'function' : function does not take number parameters

## Remarks

The function is called with an incorrect number of parameters.

Expand All @@ -20,7 +21,7 @@ C2660 can occur if you accidentally call a Windows API function rather than an M

## Examples

The following sample generates C2660.
The following example generates C2660.

```cpp
// C2660.cpp
Expand All @@ -32,7 +33,7 @@ int main() {
}
```

C2660 can also occur if you attempt to directly call the Dispose method of a managed type. For more information, see [Destructors and finalizers](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers). The following sample generates C2660.
C2660 can also occur if you attempt to directly call the Dispose method of a managed type. For more information, see [Destructors and finalizers](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers). The following example generates C2660.

```cpp
// C2660_a.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2661.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
description: "Learn more about: Compiler Error C2661"
title: "Compiler Error C2661"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2661"
ms.date: 11/04/2016
f1_keywords: ["C2661"]
helpviewer_keywords: ["C2661"]
ms.assetid: 60021467-71cd-451b-9877-23840c69309f
---
# Compiler Error C2661

'function' : no overloaded function takes number parameters
> 'function' : no overloaded function takes number parameters

## Remarks

Possible causes:

1. Incorrect actual parameters in function call.

1. Missing function declaration.

The following sample generates C2661:
## Example

The following example generates C2661:

```cpp
// C2661.cpp
Expand Down
15 changes: 9 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c2662.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2662"
title: "Compiler Error C2662"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2662"
ms.date: 11/04/2016
f1_keywords: ["C2662"]
helpviewer_keywords: ["C2662"]
ms.assetid: e172c2a4-f29e-4034-8232-e7dc6f83689f
---
# Compiler Error C2662

'function' : cannot convert 'this' pointer from 'type1' to 'type2'
> 'function' : cannot convert 'this' pointer from 'type1' to 'type2'

## Remarks

The compiler could not convert the **`this`** pointer from `type1` to `type2`.

Expand All @@ -18,7 +19,9 @@ This error can be caused by invoking a non-**`const`** member function on a **`c

- Add **`const`** to the member function.

The following sample generates C2662:
## Examples

The following example generates C2662:

```cpp
// C2662.cpp
Expand Down Expand Up @@ -60,7 +63,7 @@ ref struct N {
};
```

The following sample generates C2662:
The following example generates C2662:

```cpp
// C2662_c.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2663.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2663"
title: "Compiler Error C2663"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2663"
ms.date: 11/04/2016
f1_keywords: ["C2663"]
helpviewer_keywords: ["C2663"]
ms.assetid: 1e93e368-fd52-42bf-9908-9b6df467c8c9
---
# Compiler Error C2663

'function' : number overloads have no legal conversions for 'this' pointer
> 'function' : number overloads have no legal conversions for 'this' pointer

## Remarks

The compiler could not convert **`this`** to any of the overloaded versions of the member function.

Expand All @@ -18,7 +19,9 @@ This error can be caused by invoking a non-**`const`** member function on a **`c

1. Add **`const`** to one of the member function overloads.

The following sample generates C2663:
## Example

The following example generates C2663:

```cpp
// C2663.cpp
Expand Down
Loading