PrajwalBhat PrajwalBhat - 3 months ago 74
C Question

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

I get the following error :


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


Here is my code :

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


I have declared MAX_PATH but it still shows error in pathname

#define MAX_PATH 4096


What is the problem ?

Answer

GetFullPathName doesn't take a char *. Look at the docs, it takes LPTSTR and LPCTSTR.

Depending on your build settings, LPTSTR and related types will become either char* (ANSI builds) or wchar_t* (Unicode builds). You are building as Unicode.

Also, I don't know why you are defining MAX_PATH. That is a Windows constant so you should not re-define it.