Skip to content

Add example for C2487 #4969

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

Merged
merged 1 commit into from
Mar 4, 2024
Merged
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
20 changes: 18 additions & 2 deletions docs/error-messages/compiler-errors-1/compiler-error-c2487.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
---
description: "Learn more about: Compiler Error C2487"
title: "Compiler Error C2487"
ms.date: "11/04/2016"
ms.date: "03/04/2024"
f1_keywords: ["C2487"]
helpviewer_keywords: ["C2487"]
ms.assetid: 95d734fb-64ac-488d-b799-64f084eecb09
---
# Compiler Error C2487

'identifier' : member of dll interface class may not be declared with dll interface

You can declare a whole class, or certain members of a non-DLL interface class, with DLL interface. You cannot declare a class with DLL interface and then declare a member of that class with DLL interface.

The following sample generates C2487:

```cpp
// C2487.cpp
// compile with: /c
class __declspec(dllexport) C
{
__declspec(dllexport) void func() {} // C2487
};
```

To resolve this error, remove the DLL interface on the class or the members.

## See also

[Using `dllimport` and `dllexport` in C++ classes](../../cpp/using-dllimport-and-dllexport-in-cpp-classes.md)