In the call to CString::Format pass (LPCTSTR) strTempEntry. This will satisfy the compiler that is looking for a char* pointer not a CString object
CString -- ATL::CStringT<char, StrTraitMFCDLL format problem
Noah Aas
685
Reputation points
Hello, I got this warning. https://learn.microsoft.com/en-us/cpp/code-quality/c6284?view=msvc-160
CString Logging::AddEntry(CString strEntry)
{
SYSTEMTIME stTimestamp;
CString strNewEntry = _T("");
CString strTempEntry = strEntry;
CString strTempOldFile = _T("");
if (m_bWithTimestamp)
{
GetLocalTime(&stTimestamp);
strNewEntry.Format(_T("[%02d:%02d:%02d.%003d] %s\r\n"), stTimestamp.wHour, stTimestamp.wMinute, stTimestamp.wSecond, stTimestamp.wMilliseconds, strTempEntry);
}
// Neuer Eintrag ohne Zeitstempel
else
{
strNewEntry.Format(_T("%s\r\n"), strTempEntry);
}
How can I solve it? What is wrong? I need only CString and ANSII coding. No unicode.
framework.h stdafx.h
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#define _AFX_ALL_WARNINGS
#include <afxstr.h>
#include <atlbase.h>
#include <string>
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h>
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif
#include <afxcontrolbars.h>
#include <afxsock.h>
//https://github.com/microsoft/VCSamples/blob/master/VC2010Samples/MFC/Visual%20C%2B%2B%202008%20Feature%20Pack/OutlookDemo/stdafx.h
Thanks in advance.