Skip to content

Structure error references in range [C2351, C2380] #5578

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
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2351.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2351"
title: "Compiler Error C2351"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2351"
ms.date: 11/04/2016
f1_keywords: ["C2351"]
helpviewer_keywords: ["C2351"]
ms.assetid: 5439ccf6-66f6-4859-964c-c73f5eddfc1b
---
# Compiler Error C2351

obsolete C++ constructor initialization syntax
> obsolete C++ constructor initialization syntax

## Remarks

In a new-style initialization list for a constructor, you must explicitly name each direct base class, even if it is the only base class.

The following sample generates C2351:
## Example

The following example generates C2351:

```cpp
// C2351.cpp
Expand Down
15 changes: 9 additions & 6 deletions docs/error-messages/compiler-errors-1/compiler-error-c2352.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2352"
title: "Compiler Error C2352"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2352"
ms.date: 11/04/2016
f1_keywords: ["C2352"]
helpviewer_keywords: ["C2352"]
ms.assetid: 0efad8cb-659f-4b3e-8f6f-9f8ec44d345c
---
# Compiler Error C2352

'class::function' : illegal call of non-static member function
> 'class::function' : illegal call of non-static member function

## Remarks

A **`static`** member function called a nonstatic member function. Or, a nonstatic member function was called from outside the class as a static function.

The following sample generates C2352 and shows how to fix it:
## Examples

The following example generates C2352 and shows how to fix it:

```cpp
// C2352.cpp
Expand All @@ -28,7 +31,7 @@ public:
};
```

The following sample generates C2352 and shows how to fix it:
The following example generates C2352 and shows how to fix it:

```cpp
// C2352b.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2353.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2353"
title: "Compiler Error C2353"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2353"
ms.date: 11/04/2016
f1_keywords: ["C2353"]
helpviewer_keywords: ["C2353"]
ms.assetid: d57f8f77-d9b1-4bba-a940-87ec269ad183
---
# Compiler Error C2353

exception specification is not allowed
> exception specification is not allowed

## Remarks

Exception specifications are not allowed on member functions of managed classes.

The following sample generates C2353:
## Example

The following example generates C2353:

```cpp
// C2353.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2355.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2355"
title: "Compiler Error C2355"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2355"
ms.date: 11/04/2016
f1_keywords: ["C2355"]
helpviewer_keywords: ["C2355"]
ms.assetid: 0a947881-d61f-4f98-8409-32140f39500b
---
# Compiler Error C2355

'this' : can only be referenced inside non-static member functions or non-static data member initializers
> 'this' : can only be referenced inside non-static member functions or non-static data member initializers

## Remarks

The **`this`** pointer is valid only within non-static member functions or in non-static data member initializers. This error can result when the class scope of a member function definition outside of the class declaration is not properly qualified. The error can also occur when the **`this`** pointer is used in a function that is not declared in the class.

To fix this issue, make sure the member function definition matches a member function declaration in the class, and that it is not declared static. For data member initializers, make sure the data member is not declared static.

The following sample generates C2355 and shows how to fix it:
## Example

The following example generates C2355 and shows how to fix it:

```cpp
// C2355.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2356.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2356"
title: "Compiler Error C2356"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2356"
ms.date: 11/04/2016
f1_keywords: ["C2356"]
helpviewer_keywords: ["C2356"]
ms.assetid: 84d5a816-9a61-4d45-9978-38e485bbf767
---
# Compiler Error C2356

initialization segment must not change during translation unit
> initialization segment must not change during translation unit

## Remarks

Possible causes:

Expand All @@ -18,7 +19,9 @@ Possible causes:

To resolve, move the segment initialization code to the beginning of the module. If multiple areas must be initialized, move them to separate modules.

The following sample generates C2356:
## Example

The following example generates C2356:

```cpp
// C2356.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2357.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2357"
title: "Compiler Error C2357"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2357"
ms.date: 11/04/2016
f1_keywords: ["C2357"]
helpviewer_keywords: ["C2357"]
ms.assetid: d1083945-0ea2-4385-9e66-8c665978806c
---
# Compiler Error C2357

'identifier' : must be a function of type 'type'
> 'identifier' : must be a function of type 'type'

## Remarks

Your code declares a version of the `atexit` function that does not match the version declared internally by the compiler. Declare `atexit` as follows:

Expand All @@ -18,7 +19,9 @@ int __cdecl atexit(void (__cdecl *)());

For more information, see [init_seg](../../preprocessor/init-seg.md).

The following sample generates C2357:
## Example

The following example generates C2357:

```cpp
// C2357.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2360.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2360"
title: "Compiler Error C2360"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2360"
ms.date: 11/04/2016
f1_keywords: ["C2360"]
helpviewer_keywords: ["C2360"]
ms.assetid: 51bfd2ee-8108-4777-aa93-148b9cebfa83
---
# Compiler Error C2360

initialization of 'identifier' is skipped by 'case' label
> initialization of 'identifier' is skipped by 'case' label

## Remarks

The initialization of `identifier` can be skipped in a **`switch`** statement. You cannot jump past a declaration with an initializer unless the declaration is enclosed in a block. (Unless it is declared within a block, the variable is within scope until the end of the **`switch`** statement.)

The following sample generates C2360:
## Example

The following example generates C2360:

```cpp
// C2360.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2361.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2361"
title: "Compiler Error C2361"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2361"
ms.date: 11/04/2016
f1_keywords: ["C2361"]
helpviewer_keywords: ["C2361"]
ms.assetid: efbdaeb9-891c-4f7d-97da-89088a8413f3
---
# Compiler Error C2361

initialization of 'identifier' is skipped by 'default' label
> initialization of 'identifier' is skipped by 'default' label

## Remarks

The initialization of `identifier` can be skipped in a **`switch`** statement. You cannot jump past a declaration with an initializer unless the declaration is enclosed in a block. (Unless it is declared within a block, the variable is within scope until the end of the **`switch`** statement.)

The following sample generates C2361:
## Example

The following example generates C2361:

```cpp
// C2361.cpp
Expand Down
11 changes: 7 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2362.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2362"
title: "Compiler Error C2362"
ms.date: "06/03/2019"
description: "Learn more about: Compiler Error C2362"
ms.date: 06/03/2019
f1_keywords: ["C2362"]
helpviewer_keywords: ["C2362"]
ms.assetid: 7aafecbc-b3cf-45a6-9ec3-a17e3f222511
---
# Compiler Error C2362

> initialization of '*identifier*' is skipped by 'goto *label*'

## Remarks

When compiled by using [/Za](../../build/reference/za-ze-disable-language-extensions.md), a jump to the label prevents the identifier from being initialized.

You can only jump past a declaration with an initializer if the declaration is enclosed in a block that isn't entered, or if the variable has already been initialized.

The following sample generates C2362:
## Example

The following example generates C2362:

```cpp
// C2362.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2364.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2364"
title: "Compiler Error C2364"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2364"
ms.date: 11/04/2016
f1_keywords: ["C2364"]
helpviewer_keywords: ["C2364"]
ms.assetid: 4f550571-94b5-42ca-84cb-663fecbead44
---
# Compiler Error C2364

'type': illegal type for custom attribute
> 'type': illegal type for custom attribute

## Remarks

Named arguments for custom attributes are limited to compile time constants. For example, integral types (int, char, etc.), System::Type^, and System::Object^.

## Example

The following sample generates C2364.
The following example generates C2364.

```cpp
// c2364.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2365.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2365"
title: "Compiler Error C2365"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2365"
ms.date: 11/04/2016
f1_keywords: ["C2365"]
helpviewer_keywords: ["C2365"]
ms.assetid: 35839b0b-4055-4b79-8957-b3a0871bdd02
---
# Compiler Error C2365

'class member' : redefinition; previous definition was 'class member'
> 'class member' : redefinition; previous definition was 'class member'

## Remarks

You attempted to redefine a class member.

The following sample generates C2365.
## Example

The following example generates C2365.

```cpp
// C2365.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2368.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2368"
title: "Compiler Error C2368"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2368"
ms.date: 11/04/2016
f1_keywords: ["C2368"]
helpviewer_keywords: ["C2368"]
ms.assetid: a824626f-9fb5-453b-a3a4-da89d1e32218
---
# Compiler Error C2368

'identifier' : redefinition; different allocation specifiers
> 'identifier' : redefinition; different allocation specifiers

## Remarks

The declaration and definition of the symbol specify different **`__declspec`** attributes.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2369.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2369"
title: "Compiler Error C2369"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2369"
ms.date: 11/04/2016
f1_keywords: ["C2369"]
helpviewer_keywords: ["C2369"]
ms.assetid: 2a3933f6-2313-40ff-800f-921b296fdbbf
---
# Compiler Error C2369

'array' : redefinition; different subscripts
> 'array' : redefinition; different subscripts

## Remarks

The array is already declared with a different subscript.

The following sample generates C2369:
## Example

The following example generates C2369:

```cpp
// C2369.cpp
Expand Down
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-1/compiler-error-c2370.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2370"
title: "Compiler Error C2370"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2370"
ms.date: 11/04/2016
f1_keywords: ["C2370"]
helpviewer_keywords: ["C2370"]
ms.assetid: 03403e8f-f393-47c4-bd25-5c1c7ea7d5cd
---
# Compiler Error C2370

'identifier' : redefinition; different storage class
> 'identifier' : redefinition; different storage class

## Remarks

The identifier is already declared with a different storage class.

## Examples

The following sample generates C2370:
The following example generates C2370:

```cpp
// C2370.cpp
Expand All @@ -24,7 +25,7 @@ static int i; // C2370
int i; // OK
```

The following sample generates C2370:
The following example generates C2370:

```cpp
// C2370b.cpp
Expand Down
Loading