I implemented a function template to find a wstring
in a std::vector
with case insensitive mode :
template <class T>
long VecFindIgnoreCase(const std::vector< T >& vec, const wchar_t* sFind)
{
for (std::vector< T >::const_iterator iter = vec.begin(); iter != vec.end(); ++iter)
if (StrCmpIW((*iter).c_str(), sFind) == 0)
return (long)std::distance(vec.begin(), iter);
return -1;
}
In my code
, compiler gives a link error since using of StrCmpIW
to compare two strings with case insensitive :
error LNK2019: unresolved external symbol __imp__StrCmpIW@8 referenced in function "long __cdecl VecFindIgnoreCase<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >(class std::vector<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::allocator<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > > const &,wchar_t const *)" (??$VecFindIgnoreCase@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@@YAJABV?$vector@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@@std@@PB_W@Z)
But when I'm using of _wcsicmp
instead of StrCmpIW
every thing is ok with compiler and generate no error :
if (_wcsicmp((*iter).c_str(), sFind) == 0) // OK
if (StrCmpIW((*iter).c_str(), sFind) == 0) // Link error
(BTW i implemented the same function for string
and used of StrCmpIA
within and has no error with compiler)
Any suggestion?