Skip to content

Structure error references in range [C2851, C2880] #5644

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-2/compiler-error-c2854.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2854"
title: "Compiler Error C2854"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2854"
ms.date: 11/04/2016
f1_keywords: ["C2854"]
helpviewer_keywords: ["C2854"]
ms.assetid: 917fec9c-790a-4149-8dfc-00d17a09199c
---
# Compiler Error C2854

syntax error in #pragma hdrstop
> syntax error in #pragma hdrstop

## Remarks

The `#pragma hdrstop` gives an invalid filename. The pragma can be followed by an optional filename in parentheses and quotation marks:

The following sample generates C2854:
## Example

The following example generates C2854:

```cpp
// C2854.cpp
Expand Down
6 changes: 3 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2855.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2855"
title: "Compiler Error C2855"
description: "Learn more about: Compiler Error C2855"
ms.date: 02/16/2021
f1_keywords: ["C2855"]
helpviewer_keywords: ["C2855"]
Expand All @@ -9,10 +9,10 @@ helpviewer_keywords: ["C2855"]

> command-line option '*option*' inconsistent with precompiled header

This error occurs when a command-line option differs from the options used to create the precompiled header.

## Remarks

This error occurs when a command-line option differs from the options used to create the precompiled header.

Error C2855 can occur when you make an incremental build after changing a compiler option. It can also happen if you set specific compiler options for individual source files.

To resolve this error, regenerate the precompiled header by using the specified command-line option. To regenerate the precompiled header, build the associated source file. For example, projects created by a Visual Studio template usually create a source file named *`pch.cpp`* to generate the precompiled header. (In older versions of Visual Studio, this file is named *`stdafx.cpp`*.) In other projects, the source file to rebuild is the one built by using the [`/Yc` (Create precompiled header file)](../../build/reference/yc-create-precompiled-header-file.md) compiler option. We recommend you rebuild your entire project after making a change to the precompiled header.
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2856.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2856"
title: "Compiler Error C2856"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2856"
ms.date: 11/04/2016
f1_keywords: ["C2856"]
helpviewer_keywords: ["C2856"]
ms.assetid: fe616c51-124e-49e3-9dd8-883ec1660680
---
# Compiler Error C2856

\#pragma hdrstop cannot be inside an #if block
> #pragma hdrstop cannot be inside an #if block

## Remarks

The `hdrstop` pragma cannot be placed inside the body of a conditional compilation block.

Expand Down
11 changes: 5 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c2857.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
---
description: "Learn more about: Compiler Error C2857"
title: "Compiler Error C2857"
ms.date: "09/13/2018"
description: "Learn more about: Compiler Error C2857"
ms.date: 09/13/2018
f1_keywords: ["C2857"]
helpviewer_keywords: ["C2857"]
ms.assetid: b57302bd-58ec-45ae-992a-1e282d5eeccc
---
# Compiler Error C2857

> '#include' statement specified with the /Yc*filename* command-line option was not found in the source file

The [/Yc](../../build/reference/yc-create-precompiled-header-file.md) option specifies the name of an include file that is not included in the source file being compiled.

## Remarks

The [/Yc](../../build/reference/yc-create-precompiled-header-file.md) option specifies the name of an include file that is not included in the source file being compiled.

When you use the **/Yc**<em>filename</em> option on a source file to create a precompiled header (PCH) file, that source file must include the *filename* header file. Every file included by the source file, up to and including the specified *filename*, is included in the PCH file. In other source files compiled by using the **/Yu**<em>filename</em> option to use the PCH file, an include of *filename* must be the first non-comment line in the file. The compiler ignores anything in the source file before this include.

This error can be caused by an `#include "filename"` statement in a conditional compilation block that is not compiled in your PCH source file.

## Example

In typical usage, one source file in your project is designated as the PCH source file, and one header file is used as the PCH header file. A typical PCH header file has all of the library headers used in your project, but not local headers that are still under development. In this sample, the PCH header file is named *my_pch.h*.
In typical usage, one source file in your project is designated as the PCH source file, and one header file is used as the PCH header file. A typical PCH header file has all of the library headers used in your project, but not local headers that are still under development. In this example, the PCH header file is named *my_pch.h*.

```cpp
// my_pch.h
Expand Down
5 changes: 3 additions & 2 deletions docs/error-messages/compiler-errors-2/compiler-error-c2858.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
description: "Learn more about: Compiler Error C2858"
title: "Compiler Error C2858"
description: "Learn more about: Compiler Error C2858"
ms.date: 06/01/2022
f1_keywords: ["C2858"]
helpviewer_keywords: ["C2858"]
ms.assetid: 1fb1d770-307e-476e-9984-a1d8f8ce2820
---
# Compiler Error C2858

> command-line option '/Yc (/Fd*filename1*)' inconsistent with precompiled header, which used '/Fd*filename2*'

## Remarks

The program database specified by the Use Precompiled Header ([`/Yu`](../../build/reference/yu-use-precompiled-header-file.md)) option is not the one specified by the previous Create Precompiled Header ([`/Yc`](../../build/reference/yc-create-precompiled-header-file.md)) option.

This error is obsolete in Visual Studio 2022 and later versions.
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2859.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2859"
title: "Compiler Error C2859"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2859"
ms.date: 11/04/2016
f1_keywords: ["C2859"]
helpviewer_keywords: ["C2859"]
ms.assetid: fcfbc58d-08f6-4752-9688-8aaac517e684
---
# Compiler Error C2859

filename is not the type file that was used when this precompiled header was created, recreate the precompiled header.
> filename is not the type file that was used when this precompiled header was created, recreate the precompiled header.

## Remarks

The project database and precompiled header files must be created together to ensure consistent information. Rebuild the project to recreate the precompiled header.

Expand Down
12 changes: 8 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2860.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
---
description: "Learn more about: Compiler Error C2860"
title: "Compiler Error C2860"
ms.date: "03/16/2024"
description: "Learn more about: Compiler Error C2860"
ms.date: 03/16/2024
f1_keywords: ["C2860"]
helpviewer_keywords: ["C2860"]
---
# Compiler Error C2860

'void' cannot be used as a function parameter except for '(void)'
> 'void' cannot be used as a function parameter except for '(void)'

## Remarks

A function parameter cannot be of type **`void`**.

The following sample generates C2860:
## Example

The following example generates C2860:

```cpp
// C2860.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2861.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2861"
title: "Compiler Error C2861"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2861"
ms.date: 11/04/2016
f1_keywords: ["C2861"]
helpviewer_keywords: ["C2861"]
ms.assetid: 012bb44d-6c9b-4def-b54e-b19f1f8ddd1b
---
# Compiler Error C2861

'function name' : an interface member function cannot be defined
> 'function name' : an interface member function cannot be defined

## Remarks

The compiler encountered the interface keyword or deduced a struct as an interface but then found a member function definition. An interface cannot contain a definition for a member function.

## Example

The following sample generates C2861:
The following example generates C2861:

```cpp
// C2861.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2862.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2862"
title: "Compiler Error C2862"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2862"
ms.date: 11/04/2016
f1_keywords: ["C2862"]
helpviewer_keywords: ["C2862"]
ms.assetid: c04d8499-b799-48a1-9fb4-7902a0b0ac8e
---
# Compiler Error C2862

'interface' : an interface can only have public members
> 'interface' : an interface can only have public members

## Remarks

Protected and private members may be accessed only from other member functions. Such members are no use in an interface, since it may not provide implementations for any of its members.

The following sample will generate C2862:
## Example

The following example will generate C2862:

```cpp
// C2862.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2863.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2863"
title: "Compiler Error C2863"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2863"
ms.date: 11/04/2016
f1_keywords: ["C2863"]
helpviewer_keywords: ["C2863"]
ms.assetid: 32561d67-a795-486b-b3b6-4b90a1acb176
---
# Compiler Error C2863

'interface' : an interface cannot have friends
> 'interface' : an interface cannot have friends

## Remarks

Declaring friends on an interface is not allowed.

The following sample generates C2863:
## Example

The following example generates C2863:

```cpp
// C2863.cpp
Expand Down
7 changes: 3 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2864.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Error C2864"
title: "Compiler Error C2864"
description: "Learn more about: Compiler Error C2864"
ms.date: 10/04/2019
f1_keywords: ["C2864"]
helpviewer_keywords: ["C2864"]
ms.assetid: d0ca2ad9-90a6-4aef-8511-98a3b414c102
---
# Compiler Error C2864

Expand All @@ -16,7 +15,7 @@ To initialize a **`static`** data member that's defined as **`volatile`**, non-*

## Example

This sample generates C2864:
This example generates C2864:

```cpp
// C2864.cpp
Expand All @@ -32,7 +31,7 @@ private:
};
```

This sample shows how to fix C2864:
This example shows how to fix C2864:

```cpp
// C2864b.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2865.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2865"
title: "Compiler Error C2865"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2865"
ms.date: 11/04/2016
f1_keywords: ["C2865"]
helpviewer_keywords: ["C2865"]
ms.assetid: 973eb6a0-c99a-4d25-b3e5-fe0539794d77
---
# Compiler Error C2865

'function' : illegal comparison for handle_or_pointer
> 'function' : illegal comparison for handle_or_pointer

## Remarks

You can compare references to [Classes and Structs](../../extensions/classes-and-structs-cpp-component-extensions.md) or managed reference types only for equality to see if they refer to the same object (==) or to different objects (!=).

Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2867.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2867"
title: "Compiler Error C2867"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2867"
ms.date: 11/04/2016
f1_keywords: ["C2867"]
helpviewer_keywords: ["C2867"]
ms.assetid: 63be26b2-d9ab-4f3d-a8b7-981ce3e4d6b9
---
# Compiler Error C2867

'identifier' : is not a namespace
> 'identifier' : is not a namespace

## Remarks

A **`using`** directive is applied to something other than a namespace.

The following sample generates C2867:
## Example

The following example generates C2867:

```cpp
// C2867.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2868.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2868"
title: "Compiler Error C2868"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2868"
ms.date: 11/04/2016
f1_keywords: ["C2868"]
helpviewer_keywords: ["C2868"]
ms.assetid: 6ff5837b-e66d-44d1-9d17-80af35e08d08
---
# Compiler Error C2868

> '*identifier*' : illegal syntax for using-declaration; expected qualified-name

## Remarks

A [using declaration](../../cpp/using-declaration.md) requires a *qualified name*, a scope-operator (`::`) separated sequence of namespace, class, or enumeration names that ends with the identifier name. A single scope resolution operator may be used to introduce a name from the global namespace.

## Example

The following sample generates C2868 and also shows correct usage:
The following example generates C2868 and also shows correct usage:

```cpp
// C2868.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2869.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2869"
title: "Compiler Error C2869"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2869"
ms.date: 11/04/2016
f1_keywords: ["C2869"]
helpviewer_keywords: ["C2869"]
ms.assetid: 6e30c001-47f3-4101-b9f1-cc542c9fffae
---
# Compiler Error C2869

'name' : has already been defined to be a namespace
> 'name' : has already been defined to be a namespace

## Remarks

You cannot reuse a name already used as a namespace.

The following sample generates C2869:
## Example

The following example generates C2869:

```cpp
// C2869.cpp
Expand Down
Loading