BUG: No Warning Using Extern "C" in a Namespace (140357)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
This article was previously published under Q140357 SYMPTOMS Unexpected behavior can occur when you use extern "C" in a
namespace. CAUSE Among other things, extern "C" directs the compiler not to
decorate the names of symbols. But a symbol name is not recognized as part of a
namespace outside of a translation unit unless the namespace name is part of
the decorated name for the symbol.
The compiler should generate a
warning when using extern "C" in a namespace, but it does not. RESOLUTION Don't use extern "C" linkage in a namespace. If you have to
use extern "C" linkage, use it outside of a namespace. STATUS Microsoft has confirmed this to be a bug in the Microsoft
products listed at the beginning of this article. We are researching this
problem and will post new information here in the Microsoft Knowledge Base as
it becomes available.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbBug kbCompiler kbCPPonly kbProgramming KB140357 |
---|
|