Original Post
OK folks... mystery solving time. I have an extensive project that makes use of this little gem from CodeProject. CHighTime Error 3 error C2664: 'strlen' : cannot convert parameter 1 from 'LPCTSTR' to 'const char *' Error 4 error C2665: 'strstr' : none of the 2 overloads could convert all the argument types Error 5 error C2665: 'strstr' : none of the 2 overloads could convert all the argument types Error 6 fatal error C1903: unable to recover from previous error(s); stopping compilation If you need any more information on what's going on, let me know and I can paste a few other bits. On the other hand, if you want to get dirty, the files are small and easily inserted into a blank MFC app in VS 2008. I would really hate to rip this class out and make my project work with something else. I figure the error should be simple enough, but I just can't wrap my brain around it. Thanks folks...
Quote:This worked admirably when compiled under older versions of VS. However, when I upgraded to VS 2008, it blew up. The errors and their respective code chunks are listed here:
The CHighTime and CHighTimeSpan are two classes for replacement of COleDateTime and COleDateTimeSpan. Instead of using a double for storing the date, it uses a 64 bit integer to store the date and time. The range is +/-29000 years and the smallest time span is 0.1 microseconds.
int CHighTime::FindStr(LPCTSTR pszSource, LPCTSTR pszSub, int nStart)
{
int nLength = strlen(pszSource); // <-------- error 3
if (nStart > nLength)
return -1;
// find first
LPCTSTR pszSearch = strstr(pszSource + nStart, pszSub); // <--- error 4
// return -1 for not found
return (pszSearch == NULL) ? -1 : (int)(pszSearch - pszSource);
} // CHighTime::FindStr()
int CHighTime::ReplaceStr(LPSTR pszDest, int nDestSize, LPCTSTR pszMask, LPCTSTR pszSource)
{
int nCount, iInsertLen, iReplaceLen, iMoveLen, iDestLen;
LPSTR pSearch, pStartPos;
nCount = 0;
pStartPos = pszDest;
while ( (pSearch = strstr(pStartPos, pszMask)) != NULL) { // <--- error 5
pStartPos = pSearch + 1;
++nCount;
}
if (nCount > 0) {
iReplaceLen = strlen(pszMask);
iInsertLen = strlen(pszSource);
// Can destination take the target?
if ((int)strlen(pszDest) + nCount*(iInsertLen - iReplaceLen) > nDestSize)
return 0; // no => do nothing
iDestLen = strlen(pszDest);
pStartPos = pszDest;
while ( (pSearch = strstr(pStartPos, pszMask)) != NULL) {
iMoveLen = iDestLen - (pSearch - pszDest);
if (iReplaceLen != iInsertLen ) {
memmove(pSearch + (iInsertLen - iReplaceLen), pSearch, iMoveLen);
iDestLen += iInsertLen - iReplaceLen;
pszDest[iDestLen] = '\0';
}
memcpy(pSearch, pszSource, iInsertLen);
pStartPos = pSearch + 1;
}
}
return nCount;
} // CHighTime::ReplaceStr()