BUG: Build Errors on Non-Void Return Types for Friend Function Template (246891)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
This article was previously published under Q246891 SYMPTOMS
When building an application that has a friend template function in a nontemplated class, you may see one of the following error messages:
error C2440: '=' : cannot convert from 'void' to 'type'
Expressions of type void cannot be converted to other types.
error LNK2001: unresolved external symbol "void __cdecl Test(int)" (?Test@@YAXH@Z)
Please refer to the sample in the "More Information" section for details.
CAUSE
The compiler and linker are expecting a void return type.
RESOLUTION
Use one of the following two workarounds: - Include the friend template function implementation either in header file or in main source file.
- Change the return type of the friend function template to void. If return type is important, pass it as reference.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 10/15/2002 |
---|
Keywords: | kbBug kbCompiler kbDSupport kbLangCPP kbtemplate KB246891 |
---|
|