Microsoft KB Archive/191626: Difference between revisions
m (Text replacement - "<" to "<") |
m (Text replacement - """ to """) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
<div id="TitleRow"> | <div id="TitleRow"> | ||
= <span id="KB191626"></span>FIX: CComVariant | = <span id="KB191626"></span>FIX: CComVariant > and < Operators Cause LNK2001 Errors = | ||
Line 54: | Line 54: | ||
== SYMPTOMS == | == SYMPTOMS == | ||
If you use the | If you use the "greater than" (>) or "less than" (<) comparison operators for CComVariant, you receive the following linker error: | ||
<div class="errormessage"> | <div class="errormessage"> | ||
Line 66: | Line 66: | ||
== CAUSE == | == CAUSE == | ||
You use VarCmp() to compare two VARIANTS. This function is supposed to take four arguments. The declaration for VarCmp() in Oleauto.h is incorrect, and it takes only three arguments. ATL also calls VarCmp() incorrectly with three arguments in CComVariant::operator < and CComVariant::operator | You use VarCmp() to compare two VARIANTS. This function is supposed to take four arguments. The declaration for VarCmp() in Oleauto.h is incorrect, and it takes only three arguments. ATL also calls VarCmp() incorrectly with three arguments in CComVariant::operator < and CComVariant::operator >. | ||
</div> | </div> | ||
Line 81: | Line 81: | ||
</pre> | </pre> | ||
In Atlbase.h, change the calls to VarCmp() by passing in a fourth argument of zero. Change the code from: | In Atlbase.h, change the calls to VarCmp() by passing in a fourth argument of zero. Change the code from: | ||
<pre class="codesample">bool operator<(const VARIANT& | <pre class="codesample">bool operator<(const VARIANT& varSrc) const | ||
{ | { | ||
return VarCmp((VARIANT*)this, (VARIANT*)& | return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, | ||
LOCALE_USER_DEFAULT)==VARCMP_LT; | LOCALE_USER_DEFAULT)==VARCMP_LT; | ||
} | } | ||
bool operator | bool operator>(const VARIANT& varSrc) const | ||
{ | { | ||
return VarCmp((VARIANT*)this, (VARIANT*)& | return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, | ||
LOCALE_USER_DEFAULT)==VARCMP_GT; | LOCALE_USER_DEFAULT)==VARCMP_GT; | ||
Line 97: | Line 97: | ||
</pre> | </pre> | ||
to the following: | to the following: | ||
<pre class="codesample">bool operator<(const VARIANT& | <pre class="codesample">bool operator<(const VARIANT& varSrc) const | ||
{ | { | ||
return VarCmp((VARIANT*)this, (VARIANT*)& | return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, | ||
LOCALE_USER_DEFAULT, 0)==VARCMP_LT; | LOCALE_USER_DEFAULT, 0)==VARCMP_LT; | ||
} | } | ||
bool operator | bool operator>(const VARIANT& varSrc) const | ||
{ | { | ||
return VarCmp((VARIANT*)this, (VARIANT*)& | return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, | ||
LOCALE_USER_DEFAULT, 0)==VARCMP_GT; | LOCALE_USER_DEFAULT, 0)==VARCMP_GT; | ||
} | } | ||
</pre> | </pre> | ||
You must do a | You must do a "Rebuild All" to bring in the new changes. | ||
</div> | </div> | ||
Line 130: | Line 130: | ||
== MORE INFORMATION == | == MORE INFORMATION == | ||
VarCmp() is implemented only in a newer version of Oleaut32.dll (2.30.4261 or later). If you use the CComVariant | VarCmp() is implemented only in a newer version of Oleaut32.dll (2.30.4261 or later). If you use the CComVariant > or < operators, you must distribute Oleaut32.dll via Vbrun60.exe. For more information, refer to Redist.wri in the VC98\Redist directory on the Visual C++ CD. | ||
</div> | </div> |
Latest revision as of 12:42, 21 July 2020
Article ID: 191626
Article Last Modified on 2/24/2004
APPLIES TO
- Microsoft ActiveX Template Library 3.0, when used with:
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
This article was previously published under Q191626
SYMPTOMS
If you use the "greater than" (>) or "less than" (<) comparison operators for CComVariant, you receive the following linker error:
CAUSE
You use VarCmp() to compare two VARIANTS. This function is supposed to take four arguments. The declaration for VarCmp() in Oleauto.h is incorrect, and it takes only three arguments. ATL also calls VarCmp() incorrectly with three arguments in CComVariant::operator < and CComVariant::operator >.
RESOLUTION
In OLEAUTO.H, change the declaration for VarCmp() from:
STDAPI VarCmp(LPVARIANT pvarLeft, LPVARIANT pvarRight, LCID lcid);
to the following:
STDAPI VarCmp(LPVARIANT pvarLeft, LPVARIANT pvarRight, LCID lcid, ULONG dwFlags);
In Atlbase.h, change the calls to VarCmp() by passing in a fourth argument of zero. Change the code from:
bool operator<(const VARIANT& varSrc) const { return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT)==VARCMP_LT; } bool operator>(const VARIANT& varSrc) const { return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT)==VARCMP_GT; }
to the following:
bool operator<(const VARIANT& varSrc) const { return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)==VARCMP_LT; } bool operator>(const VARIANT& varSrc) const { return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)==VARCMP_GT; }
You must do a "Rebuild All" to bring in the new changes.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:
194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
MORE INFORMATION
VarCmp() is implemented only in a newer version of Oleaut32.dll (2.30.4261 or later). If you use the CComVariant > or < operators, you must distribute Oleaut32.dll via Vbrun60.exe. For more information, refer to Redist.wri in the VC98\Redist directory on the Visual C++ CD.
Keywords: kbbug kbfix kbvs600sp3fix KB191626