Const Char Lpcwstr Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Cannot Convert From Const Char To Lpctstr
About Us Learn more about Stack Overflow the company Business Learn more about cannot convert from 'const char [14]' to 'lpcwstr' hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join how to convert const char to lpctstr in c++ the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up cannot convert parameter 1
Const Wchar_t *' To 'lpcstr'
from 'char *' to 'LPCWSTR' up vote 15 down vote favorite 5 Im trying to load a BMP file AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image { FILE *File=NULL; // File Handle if (!Filename) // Make Sure A Filename Was Given { return NULL; // If Not Return NULL } File=fopen(Filename,"r"); // Check To See If The File Exists if (File) // Does The File
Convert Char* To Lpcwstr
Exist? { fclose(File); // Close The Handle return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer } return NULL; // If Load Failed Return NULL } this has come from an example however i'm now getting the error error C2664: 'auxDIBImageLoadW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR' how could I correct this? c++ visual-c++ opengl char bmp share|improve this question edited Nov 1 '12 at 3:23 genpfault 35.4k83776 asked Mar 30 '11 at 0:32 dactz 82113 what type is Filename ? –mateuscb Mar 30 '11 at 0:47 add a comment| 5 Answers 5 active oldest votes up vote 28 down vote You're compiling your application with Character-Set set to UNICODE (Project Settings -> Configuration Options -> General). Windows header files use #defines to "map" function names to either nameA (for multi-byte strings) or nameW (for unicode strings). That means somewhere in a header file there will be a #define like this #define auxDIBImageLoad auxDIBImageLoadW So you're not actually calling auxDIBImageLoad (there is no function with that name), you're calling auxDIBImageLoadW. And auxDIBImageLoadW expects a unicode string (wchar_t const*). You're passing a multi-byte string (char const*). You ca
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site cannot convert parameter 1 from 'char *' to 'lpcwstr' About Us Learn more about Stack Overflow the company Business Learn more about
Cannot Convert Argument 1 From 'char *' To 'lpcwstr'
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss const char is incompatible with lpcwstr Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Cannot convert parameter http://stackoverflow.com/questions/5480588/cannot-convert-parameter-1-from-char-to-lpcwstr 2 from 'const char [14]' to 'LPCWSTR' up vote 2 down vote favorite I am getting this error: cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR' With the code below. It is supposed to be C but at best visual studio 2012 offers an empty c++ project: #include "windows.h" int WINAPI WinMain (HINSTANCE hinst, HINSTANCE hprevinst, LPSTR cmdline, int showcmd) { MessageBox(NULL, "Merhaba http://stackoverflow.com/questions/15592906/cannot-convert-parameter-2-from-const-char-14-to-lpcwstr Dunya", "Merhaba", MB_OK); return 0; } What is incorrect? c visual-studio-2012 lpcwstr share|improve this question edited May 21 '15 at 15:54 cpburnz 6,396144878 asked Mar 23 '13 at 22:36 MonsterMMORPG 6,16141121220 L"Merhaba Dunya" –Floris Velleman Mar 23 '13 at 22:38 1 @FlorisVelleman You beat it to me by 9 seconds! –user529758 Mar 23 '13 at 22:38 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote accepted It seems your current settings are set up so that WinAPI functions expect wide strings: MessageBox(NULL, L"Merhaba Dunya", L"Merhaba", MB_OK); share|improve this answer answered Mar 23 '13 at 22:38 user529758 thanks but still not working. seems like i need to get native C IDE. –MonsterMMORPG Mar 23 '13 at 23:02 @MonsterMMORPG I don't know what do you mean by that... what's a "native C IDE"? How would this have anything to do with the IDE? –user529758 Mar 24 '13 at 5:08 nevermind me. i installed dev-c++ and it works there –MonsterMMORPG Mar 24 '13 at 10:12 add a comment| up vote 1 down vote Right click on your project, go to properties under
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more http://stackoverflow.com/questions/14370982/converting-const-char-to-lpctstr-for-createdirectory about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Converting 'const char*' to 'LPCTSTR' for CreateDirectory up vote 2 down const char vote favorite #include "stdafx.h" #include