Skip to content

Commit 4516872

Browse files
authored
Merge pull request #4969 from Rageking8/add-example-for-c2487
Add example for C2487
2 parents d19ee24 + 974053a commit 4516872

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
---
22
description: "Learn more about: Compiler Error C2487"
33
title: "Compiler Error C2487"
4-
ms.date: "11/04/2016"
4+
ms.date: "03/04/2024"
55
f1_keywords: ["C2487"]
66
helpviewer_keywords: ["C2487"]
7-
ms.assetid: 95d734fb-64ac-488d-b799-64f084eecb09
87
---
98
# Compiler Error C2487
109

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

1312
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.
13+
14+
The following sample generates C2487:
15+
16+
```cpp
17+
// C2487.cpp
18+
// compile with: /c
19+
class __declspec(dllexport) C
20+
{
21+
__declspec(dllexport) void func() {} // C2487
22+
};
23+
```
24+
25+
To resolve this error, remove the DLL interface on the class or the members.
26+
27+
## See also
28+
29+
[Using `dllimport` and `dllexport` in C++ classes](../../cpp/using-dllimport-and-dllexport-in-cpp-classes.md)

0 commit comments

Comments
 (0)