IntelliSense:类型为“ const char *”的参数与类型为“ LPCWSTR”的参数不兼容

Pra*_*hat 2 c c++ intellisense visual-studio

我收到以下错误:

argument of type "const char *" is incompatible with parameter of type "LPCWSTR"

这是我的代码:

static char *getFmuPath(const char *fileName) {
    char pathName[MAX_PATH];
    int n = GetFullPathName(fileName, MAX_PATH, pathName, NULL);
    return n ? strdup(pathName) : NULL;
}
Run Code Online (Sandbox Code Playgroud)

我已经声明了,MAX_PATH但是路径名仍然显示错误

#define MAX_PATH 4096
Run Code Online (Sandbox Code Playgroud)

问题是什么 ?

ten*_*our 5

GetFullPathName不需要char *。查看文档,它需要LPTSTRLPCTSTR

根据您的构建设置,LPTSTR相关的类型将变为char*(ANSI构建)或wchar_t*(Unicode构建)。您正在构建为Unicode。

另外,我不知道您为什么要定义MAX_PATH。这是Windows常量,因此您不应重新定义它。