본문 바로가기

프로그래밍/MFC

error C2663: 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::GetBuffer' : ...





출처 : http://social.msdn.microsoft.com/Forums/ko-KR/vclanguage/thread/55d18da3-8ff5-462b-9852-969e5b80abf2

VS6.0에서 컴파일 잘 되던 것이 VS2005로 오면서 에러가 나는 부분입니다.

error C2663: 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::GetBuffer' : 2 overloads have no legal conversion for 'this' pointer

해결방법은 아래와 같습니다.

Definition of GetAt in Visual studio 6 as follows:
CString GetAt(int nIndex) const;

Definition of GetAt in Visual studio 2005 as follows:
const CString& GetAt(INT_PTR nIndex) const;


"strcpy(ptr->ncp_acct, pSplitAcctArr->GetAt(i).GetBuffer(0));" line should be changed to

CString csTemp = pSplitAcctArr->GetAt(i);
strcpy(ptr->ncp_acct, csTemp.GetBuffer(0));

Or

strcpy(ptr->ncp_acct, ((CString)pSplitAcctArr->GetAt(i)).GetBuffer(0));