高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】problem using getfilename
problem using getfilename
problem using getfilename
i have just upgraded to vs2005 and downloaded the new libraries.
now i have encountered a problem with the 2.5.1 libraries:
(lpctstr)pdb->getfilename().c_str();
returns "c"
i was trying to pass the filename as a cstring object to a function.
however, if i do:
afxmessagebox(pdb->getfilename()) it shows the full path.
so what has changed here?
andrew
if i remove the .c_str() from my code then it works ok. but this code was fine for vc6 libraries.
andrew
i think the effect is caused not by changing compiler but by changed meaning of lpctstr (unicode / char)
pdb->getfilename().c_str()
returns pointer to odchar (unicode string)
if lpctstr is char* than explicit cast to it casts wchar_t* to char* - you see single character.
if lpctstr is wchar_t* than it works ok.
after removing .c_str() it works always because
odstring operator (const char*) correctly converts unicode string to char. or odstring operator (const wchar_t*) is invoked depending on meaning of lpctstr.
sergey slezkin
|