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
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
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.
Describes an object that controls a varying-length sequence of elements. The sequence is stored as a singly-linked list of nodes, each containing a member of type `Type`.
@@ -32,7 +34,7 @@ A `forward_list` object allocates and frees storage for the sequence it controls
32
34
> [!NOTE]
33
35
> The stored allocator object is not copied when the container object is assigned.
34
36
35
-
Iterators, pointers and references might become invalid when elements of their controlled sequence are erased through `forward_list`. Insertions and splices performed on the controlled sequence through `forward_list` do not invalidate iterators.
37
+
Iterators, pointers and references might become invalid when elements of their controlled sequence are erased through `forward_list`. Insertions and splices performed on the controlled sequence through `forward_list` don't invalidate iterators.
36
38
37
39
Additions to the controlled sequence might occur by calls to [forward_list::insert_after](#insert_after), which is the only member function that calls the constructor `Type(const T&)`. `forward_list` might also call move constructors. If such an expression throws an exception, the container object inserts no new elements and rethrows the exception. Thus, an object of type `forward_list` is left in a known state when such exceptions occur.
38
40
@@ -211,9 +213,9 @@ A **`const`** forward-access iterator that points at the first element of the ra
211
213
212
214
### Remarks
213
215
214
-
With the return value of `cbegin`, the elements in the range cannot be modified.
216
+
With the return value of `cbegin`, the elements in the range can't be modified.
215
217
216
-
You can use this member function in place of the `begin()` member function to guarantee that the return value is `const_iterator`. Typically, it's used in conjunction with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `begin()` and `cbegin()`.
218
+
You can use this member function in place of the `begin()` member function to guarantee that the return value is `const_iterator`. Typically, it's used with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `begin()` and `cbegin()`.
217
219
218
220
```cpp
219
221
auto i1 = Container.begin();
@@ -238,7 +240,7 @@ A forward-access iterator that points just beyond the end of the range.
238
240
239
241
`cend` is used to test whether an iterator has passed the end of its range.
240
242
241
-
You can use this member function in place of the `end()` member function to guarantee that the return value is `const_iterator`. Typically, it's used in conjunction with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `end()` and `cend()`.
243
+
You can use this member function in place of the `end()` member function to guarantee that the return value is `const_iterator`. Typically, it's used with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `end()` and `cend()`.
242
244
243
245
```cpp
244
246
auto i1 = Container.end();
@@ -248,7 +250,7 @@ auto i2 = Container.cend();
248
250
// i2 is Container<T>::const_iterator
249
251
```
250
252
251
-
The value returned by `cend`should not be dereferenced.
253
+
The value returned by `cend`shouldn't be dereferenced.
`const_iterator` describes an object that can serve as a constant forward iterator for the controlled sequence. It is described here as a synonym for an implementation-defined type.
277
+
`const_iterator` describes an object that can serve as a constant forward iterator for the controlled sequence. It's described here as a synonym for an implementation-defined type.
276
278
277
279
## <aname="const_pointer"></a> const_pointer
278
280
@@ -457,7 +459,7 @@ The initializer_list to copy.
457
459
458
460
### Remarks
459
461
460
-
All constructors store an [allocator](../standard-library/allocator-class.md) and initialize the controlled sequence. The allocator object is the argument *Al*, if present. For the copy constructor, it is `right.get_allocator()`. Otherwise, it is`Allocator()`.
462
+
All constructors store an [allocator](../standard-library/allocator-class.md) and initialize the controlled sequence. The allocator object is the argument *Al*, if present. For the copy constructor, it's `right.get_allocator()`. Otherwise, it's`Allocator()`.
461
463
462
464
The first two constructors specify an empty initial controlled sequence.
`iterator` describes an object that can serve as a forward iterator for the controlled sequence. It is described here as a synonym for an implementation-defined type.
566
+
`iterator` describes an object that can serve as a forward iterator for the controlled sequence. It's described here as a synonym for an implementation-defined type.
565
567
566
568
## <aname="max_size"></a> max_size
567
569
@@ -926,7 +928,7 @@ The forward list providing the elements to be exchanged.
926
928
927
929
### Remarks
928
930
929
-
The member function swaps the controlled sequences between **`*this`** and *right*. If `get_allocator() == right.get_allocator()`, it does so in constant time, it throws no exceptions, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
931
+
The member function swaps the controlled sequences between **`*this`** and *right*. If `get_allocator() == right.get_allocator()`, it does so in constant time, it throws no exceptions, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
The class template describes an object that can store all the information needed to restore an arbitrary file-position indicator within any stream. An object of class fpos\<**St**> effectively stores at least two member objects:
@@ -38,7 +40,7 @@ State information.
38
40
39
41
|Member function|Description|
40
42
|-|-|
41
-
|[seekpos](#seekpos)|Used internally by the C++ Standard Library only. Do not call this method from your code.|
43
+
|[seekpos](#seekpos)|Used internally by the C++ Standard Library only. Don't call this method from your code.|
42
44
|[state](#state)|Sets or returns the conversion state.|
43
45
44
46
### Operators
@@ -82,7 +84,7 @@ The offset into the stream.
82
84
83
85
### Remarks
84
86
85
-
The first constructor stores the offset *_Off*, relative to the beginning of file and in the initial conversion state (if that matters). If *_Off* is -1, the resulting object represents an invalid stream position.
87
+
The first constructor stores the offset *_Off*, relative to the beginning of file and in the initial conversion state. If *_Off* is -1, the resulting object represents an invalid stream position.
86
88
87
89
The second constructor stores a zero offset and the object *_State*.
88
90
@@ -101,7 +103,7 @@ The file-position indicator against which to compare.
101
103
102
104
### Return Value
103
105
104
-
**`true`** if the file-position indicators are not equal, otherwise **`false`**.
106
+
**`true`** if the file-position indicators aren't equal, otherwise **`false`**.
105
107
106
108
### Remarks
107
109
@@ -178,7 +180,7 @@ The position in the file.
178
180
179
181
### Remarks
180
182
181
-
The member function returns **fpos(\*this) +=**`_Off`.
183
+
The member function returns **`fpos(*this) +=_Off`**.
182
184
183
185
### Example
184
186
@@ -203,7 +205,7 @@ The position in the file.
203
205
204
206
### Remarks
205
207
206
-
The member function adds *_Off* to the stored offset member object and then returns **\*this**. For positioning within a file, the result is generally valid only for binary streams that do not have a state-dependent encoding.
208
+
The member function adds *_Off* to the stored offset member object and then returns **`*this`**. When working with files, the result is valid only for binary streams that don't have a state-dependent encoding.
207
209
208
210
### Example
209
211
@@ -254,7 +256,7 @@ The member function returns `fpos(*this) -= _Off`.
254
256
255
257
### Remarks
256
258
257
-
For positioning within a file, the result is generally valid only for binary streams that do not have a state-dependent encoding.
259
+
When working with files, the result is valid only for binary streams that don't have a state-dependent encoding.
258
260
259
261
### Example
260
262
@@ -326,7 +328,7 @@ int main( )
326
328
327
329
## <aname="seekpos"></a> fpos::seekpos
328
330
329
-
This method is used internally by the C++ Standard Library only. Do not call this method from your code.
331
+
This method is used internally by the C++ Standard Library only. Don't call this method from your code.
Describes an iterator adaptor that satisfies the requirements of an output iterator. It inserts, rather than overwrites, elements into the front of a sequence and thus provides semantics that are different from the overwrite semantics provided by the iterators of the C++ sequence containers. The `front_insert_iterator` class is templatized on the type of container.
13
+
Describes an iterator adaptor that satisfies the requirements of an output iterator. It inserts, rather than overwrites, elements into the front of a sequence. Thus it provides semantics that are different from the overwrite semantics provided by the iterators of the C++ sequence containers. The `front_insert_iterator` class is templatized on the type of container.
12
14
13
15
## Syntax
14
16
@@ -24,7 +26,7 @@ The type of container into the front of which elements are to be inserted by a `
24
26
25
27
## Remarks
26
28
27
-
The container must satisfy the requirements for a front insertion sequence where is it possible to insert elements at the beginning of the sequence in amortized constant time. The C++ Standard Library sequence containers defined by the [deque Class](../standard-library/deque-class.md) and [list Class](../standard-library/list-class.md) provide the needed `push_front` member function and satisfy these requirements. By contrast, sequence containers defined by the [vector Class](../standard-library/vector-class.md)do not satisfy these requirements and cannot be adapted to use with `front_insert_iterator`s. A `front_insert_iterator` must always be initialized with its container.
29
+
The container must satisfy the requirements for a front insertion sequence where is it possible to insert elements at the beginning of the sequence in amortized constant time. The C++ Standard Library sequence containers defined by the [deque Class](../standard-library/deque-class.md) and [list Class](../standard-library/list-class.md) provide the needed `push_front` member function and satisfy these requirements. By contrast, sequence containers defined by the [vector Class](../standard-library/vector-class.md)don't satisfy these requirements and can't be adapted to use with `front_insert_iterator`s. A `front_insert_iterator` must always be initialized with its container.
28
30
29
31
### Constructors
30
32
@@ -172,7 +174,7 @@ The member function returns the value of the element addressed.
172
174
173
175
### Remarks
174
176
175
-
Used to implement the output iterator expression **\*Iter** = **value**. If `Iter` is an iterator that addresses an element in a sequence, then **\*Iter** = **value** replaces that element with value and does not change the total number of elements in the sequence.
177
+
Used to implement the output iterator expression **\*Iter** = **value**. If `Iter` is an iterator that addresses an element in a sequence, then **\*Iter** = **value** replaces that element with value and doesn't change the total number of elements in the sequence.
0 commit comments