Skip to content

Commit 15055f4

Browse files
authored
Update compiler-warning-levels-2-and-4-c4200.md
1 parent 51f0dfc commit 15055f4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

docs/error-messages/compiler-warnings/compiler-warning-levels-2-and-4-c4200.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ helpviewer_keywords: ["C4200"]
99

1010
> nonstandard extension used: zero-sized array in struct/union
1111
12-
Indicates that a structure or union contains an array that has zero size.
13-
14-
Declaration of a zero-sized array is a Microsoft extension. This causes a Level-2 warning when a C++ file is compiled and a Level-4 warning when a C file is compiled. C++ compilation also gives this warning: "Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array." This example generates warning C4200:
12+
C++ only:
13+
> This member will be ignored by a defaulted constructor or copy/move assignment operator
14+
15+
This warning indicates that a structure or union contains an array that has zero size. Declaration of a zero-sized array is a nonstandard compiler extension. This causes a Level-2 warning when a C++ file is compiled and a Level-4 warning when a C file is compiled. This example generates warning C4200:
1516

1617
```cpp
1718
// C4200.cpp
1819
// compile by using: cl /W4 c4200.cpp
1920
struct A {
21+
int len;
2022
int a[0]; // C4200
2123
};
22-
int main() {
23-
}
2424
```
2525
26-
This non-standard extension is often used to interface code with external data structures that have a variable length. If this scenario applies to your code, you can disable the warning:
26+
This nonstandard extension is often used to interface code with external data structures that have a variable length. If this scenario applies to your code, you can disable the warning:
2727
2828
## Example
2929
@@ -32,8 +32,7 @@ This non-standard extension is often used to interface code with external data s
3232
// compile by using: cl /W4 c4200a.cpp
3333
#pragma warning(disable : 4200)
3434
struct A {
35+
int len;
3536
int a[0];
3637
};
37-
int main() {
38-
}
3938
```

0 commit comments

Comments
 (0)