【发布时间】:2020-12-05 21:07:52
【问题描述】:
我是 Windows 上 C/C++ 编码的新手,在运行我的代码时遇到了这个错误。之前有人问了一个类似的问题,我将在下面链接,但是,这个解决方案对我不起作用,因为我没有更改我的字符集的选项。
argument of type const char* is incompatible with parameter of type "LPCWSTR"
这是我的代码的样子。
#include <Windows.h>
INT CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCmdLine, INT nCmdShow)
{
OutputDebugString("Lets test this out \n");
return 0;
}
【问题讨论】:
-
你试过
OutputDebugString(L"Lets test this out \n");吗?请注意使用 w 版本的std::wstring和 I/O 类 (wostream)。 -
或者调用
OutputDebugStringA,考虑到正在传递的字符串以及OutputDebugStringW的工作原理,这似乎是首选路由。 -
@πάνταῥεῖ 成功了!谢谢!我对此有点陌生,但 L 是什么意思?
-
@User9123 宽字符串字面量。
标签: c++ windows visual-studio