Skip to content

Commit c9ab203

Browse files
authored
Merge pull request #260 from Microsoft/cr-new-error
Fix two error messages
2 parents 6301502 + 0123840 commit c9ab203

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

docs/error-messages/compiler-errors-1/compiler-error-c2280.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct A {
8282

8383
## Example: Reference and const data members
8484

85-
A `const` or reference type data member causes the compiler to declare a `deleted` copy assignment operator. Once initialized, these members can't be assigned to. To fix this issue, we recommend you change your logic to remove the assignment operations that cause the error.
85+
A `const` or reference type data member causes the compiler to declare a `deleted` copy assignment operator. Once initialized, these members can't be assigned to, so a simple copy or move can't work. To fix this issue, we recommend you change your logic to remove the assignment operations that cause the error.
8686

8787
```cpp
8888
// C2280_ref.cpp

docs/error-messages/compiler-errors-2/compiler-error-c2872.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,31 @@ translation.priority.ht:
3535
- "zh-tw"
3636
---
3737
# Compiler Error C2872
38-
'symbol' : ambiguous symbol
38+
'*symbol*' : ambiguous symbol
3939

40-
The compiler cannot determine which symbol you are referring to.
40+
The compiler cannot determine which symbol you are referring to. More than one symbol with the specified name is in scope. See the notes following the error message for the file locations and declarations the compiler found for the ambiguous symbol. To fix this issue, you can fully qualify the ambiguous symbol by using its namespace, for example, `std::byte` or `::byte`. You can also use a [namespace alias](../../cpp/namespaces-cpp.md#namespace_aliases) to give an included namespace a convenient short name for use when disambiguating symbols in your source code.
4141

42-
C2872 can occur if a header file includes a [using directive](../../cpp/namespaces-cpp.md#using_directives), and a subsequent header file is included and it contains a type that is also in the namespace specified in the `using` directive. Specify a `using` directive only after all your header files are specified with `#include`.
42+
C2872 can occur if a header file includes a [using directive](../../cpp/namespaces-cpp.md#using_directives), and a subsequent header file is included that contains a type that is also in the namespace specified in the `using` directive. Specify a `using` directive only after all your header files are specified with `#include`.
4343

4444
For more information about C2872, see Knowledge Base articles [PRB: Compiler Errors When You Use #import with XML in Visual C++ .NET](http://support.microsoft.com/kb/316317) and ["Error C2872: 'Platform' : ambiguous symbol" error message when you use the Windows::Foundation::Metadata namespace in Visual Studio 2013](https://support.microsoft.com/kb/2890859).
4545

4646
## Example
47-
The following sample generates C2872:
47+
The following sample generates C2872, because an ambiguous reference is made to a variable named `i`; two variables with the same name are in scope:
4848

4949
```cpp
5050
// C2872.cpp
51+
// compile with: cl /EHsc C2872.cpp
5152
namespace A {
5253
int i;
5354
}
5455

5556
using namespace A;
5657
int i;
5758
int main() {
58-
::i++; // ok
59-
A::i++; // ok
60-
i++; // C2872 ::i or A::i?
59+
::i++; // ok, uses i from global namespace
60+
A::i++; // ok, uses i from namespace A
61+
i++; // C2872 ambiguous: ::i or A::i?
62+
// To fix this issue, use the fully qualified name
63+
// for the intended variable.
6164
}
6265
```

0 commit comments

Comments
 (0)