You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d07907b
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/error-messages/compiler-warnings/compiler-warning-level-1-c4743.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,33 @@
1
1
---
2
2
description: "Learn more about: Compiler Warning (Level 1) C4743"
3
3
title: "Compiler Warning (Level 1) C4743"
4
-
ms.date: "05/13/2019"
4
+
ms.date: 06/16/2022
5
5
f1_keywords: ["C4743"]
6
6
helpviewer_keywords: ["C4743"]
7
7
ms.assetid: 2ee76ea3-77f3-4c2f-9a57-0751823c89fd
8
8
---
9
9
# Compiler Warning (Level 1) C4743
10
10
11
-
'*type*' has different size in '*file1*' and '*file2*': *number* and *number* bytes
11
+
> '*type*' has different size in '*file1*' and '*file2*': *size_1* and *size_2* bytes
12
12
13
13
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*.
14
14
15
15
## Remarks
16
16
17
-
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.
17
+
There's an important case when this warning can be emitted for C++. If you declare class types with the same name in two different files, if those declarations contain virtual functions, and if the declarations aren't 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 the linker must choose one of them to incorporate into the executable. It's possible that it can result in your program calling the wrong virtual function.
18
18
19
19
To resolve this warning, either use the same type definition or use different names for the types or variables.
20
20
21
21
## Example
22
22
23
-
The following sample generates C4743. To compile it, place both files in the same folder, then run
23
+
The following sample generates C4743. To compile it, place both files in the same folder, then run this command in a developer command prompt:
24
24
25
25
```cmd
26
26
cl /EHsc /W1 /GL /O2 C4743a.cpp C4743b.cpp
27
27
```
28
28
29
+
Source file *`C4743a.cpp`*:
30
+
29
31
```cpp
30
32
// C4743a.cpp
31
33
classC {
@@ -41,6 +43,8 @@ void C::f3(void) {}
41
43
C q;
42
44
```
43
45
46
+
Source file *`C4743b.cpp`*:
47
+
44
48
```cpp
45
49
// C4743b.cpp
46
50
class C {
@@ -58,3 +62,5 @@ C x;
58
62
59
63
int main() {}
60
64
```
65
+
66
+
To resolve this issue, rename one of the `C` classes.
0 commit comments