开发者

Any side effect of not using USES_CONVERSION

Recently I made a utilities function like:

// T2CA
#include "ATLCONV.H"

std::string Utils::CString2String(const CString& cString) 
{
#if _MSC_VER > 1200
    // Convert a TCHAR string to a开发者_JAVA技巧 LPCSTR
    // construct a std::string using the LPCSTR input
    CT2CA tmp(cString);
    std::string strStd (tmp);
#else
    // Deprecated in VC2008.
    // construct a std::string using the LPCSTR input

    std::string strStd (T2CA (cString));
#endif

    return strStd;
}

I did several simple tests and it seems to work fine. However, when I search the web I can see that most usages of T2CA in VC6 have a preceding call of

USES_CONVERSION;

Is there anything that I had missed? Should I invoke my function by :

#else
    // Deprecated in VC2008.
    // construct a std::string using the LPCSTR input
    USES_CONVERSION;
    std::string strStd (T2CA (cString));
#endif


In ATL 7.0 USES_CONVERSION is not required anymore. Before that you needed to specify the USES_CONVERSION macro or else you'd get compile errors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜