Skip to content

Commit 38a4863

Browse files
authored
Merge pull request MicrosoftDocs#2002 from mikeblome/mb-gh497
fix per Colin's suggestion in GH Issue 497
2 parents 6271d98 + 5ee1521 commit 38a4863

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4743.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Compiler Warning (Level 1) C4743"
3-
ms.date: "11/04/2016"
3+
ms.date: "05/13/2019"
44
f1_keywords: ["C4743"]
55
helpviewer_keywords: ["C4743"]
66
ms.assetid: 2ee76ea3-77f3-4c2f-9a57-0751823c89fd
@@ -11,17 +11,22 @@ ms.assetid: 2ee76ea3-77f3-4c2f-9a57-0751823c89fd
1111

1212
An external variable referenced or defined in two files has different types in those files, and the compiler determined that the size of the variable in *file1* differs from the size of the variable in *file2*.
1313

14-
There is important case when this warning can be emitted for C++. If you declare the same types with the same name in two different files, if those declarations contain virtual functions, and if the declarations are not the same, then the compiler can emit warning C4744 for the virtual function tables. The warning occurs because there are two different sized virtual function tables for the same type, and linker must choose one of them to incorporate into the executable. It is possible that this can result in your program calling the wrong virtual function.
14+
## Remarks
15+
16+
There is an important case when this warning can be emitted for C++. If you declare the same types with the same name in two different files, if those declarations contain virtual functions, and if the declarations are not the same, then the compiler can emit warning C4744 for the virtual function tables. The warning occurs because there are two different-sized virtual function tables for the same type, and linker must choose one of them to incorporate into the executable. It is possible that it can result in your program calling the wrong virtual function.
1517

1618
To resolve this warning, either use the same type definition or use different names for the types or variables.
1719

1820
## Example
1921

20-
This sample contains one definition of the type.
22+
The following sample generates C4743. To compile it, place both files in the same folder, then run
2123

24+
```cmd
25+
cl /EHsc /W1 /GL /O2 C4743a.cpp C4743b.cpp
2226
```
27+
28+
```cpp
2329
// C4743a.cpp
24-
// compile with: /c
2530
class C {
2631
public:
2732
virtual void f1(void);
@@ -35,14 +40,8 @@ void C::f3(void) {}
3540
C q;
3641
```
3742
38-
## Example
39-
40-
The following sample generates C4743.
41-
42-
```
43+
```cpp
4344
// C4743b.cpp
44-
// compile with: C4743a.cpp /W1 /GL /O2
45-
// C4743 expected
4645
class C {
4746
public:
4847
virtual void f1(void);
@@ -57,4 +56,4 @@ void C::f5(void) {}
5756
C x;
5857
5958
int main() {}
60-
```
59+
```

0 commit comments

Comments
 (0)