const char *到LPTSTR [英] const char* to LPTSTR

查看:163
本文介绍了const char *到LPTSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调用一个接受LPTSTR作为参数的函数。我用一个字符串文字调用它,如在foo(bar);

I am trying to call a function that accepts an LPTSTR as a parameter. I am calling it with a string literal, as in foo("bar");

我得到一个错误,我不能转换参数1从' ]'to'LPTSTR',但我不知道为什么或如何解决它。任何帮助将是巨大的。

I get an error that I "cannot convert parameter 1 from 'const char [3]' to 'LPTSTR'", but I have no idea why or how to fix it. Any help would be great.

推荐答案

您可能已经定义了UNICODE,LPTSTR扩展为wchar_t *。对字符串文字使用TEXT宏,以避免出现问题,例如 foo(TEXT(bar))

You probably has UNICODE defined, and LPTSTR expands into wchar_t*. Use TEXT macro for string literals to avoid problems with that, e.g. foo(TEXT("bar")).

这篇关于const char *到LPTSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆