Error C2664 Visual Studio
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 About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads error c2664 cannot convert parameter with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the error c2664 cannot convert parameter 1 from 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: error c2664 in c++ Sign up C2664 error c++ Visual Studio up vote 0 down vote favorite I am trying to modify an old MFC program. After opening the project in Visual Studio 2013 there are many errors of the type below. In AviPlay.cpp #include "stdafx.h"
Error C2664 Lpcwstr
#include "AviPlay.h" #define OPEN_AVI_VIDEO "open avivideo" BOOL initAVI() { return mciSendString(OPEN_AVI_VIDEO, NULL, 0, NULL) == 0; } The error thrown is error C2664: 'MCIERROR mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND)' : cannot convert argument 1 from 'const char [14]' to 'LPCWSTR' Should setting the compiler option for Strict to off, or some other compiler option, resolve this error? If not, I can modify the many lines of code manually. In that case, what might have changed in the last 15 years that would make code like this OK error c2664 cannot convert argument before but not OK now? Thank you in advance. c++ visual-studio-2013 c2664 share|improve this question asked Aug 12 '14 at 1:44 user3931552 11 1 You could try setting the project type to multibyte rather than unicode, but I do not know if that is a valid option when using MFC. –Retired Ninja Aug 12 '14 at 1:48 The project might be set to unicode character set. This would cause your program to link to the wide version of mciSendStringW rather than the multibyte version mciSendStringA. –Beed Aug 12 '14 at 1:49 Setting to multibyte in project properties, general, character set fixed my problem. Thank you very much! –user3931552 Aug 14 '14 at 17:14 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote LPCWSTR tells you it is expecting a wchar_t string, not a char string. By default, all Windows APIs now accept wchar_t strings (unicode). You can change it back to char strings in the project properties, General page, Character Set. Setting it to 'Use Multibyte char set' will get it working as it used to. share|improve this answer answered Aug 12 '14 at 1:54 ScottMcP-MVP 8,9592613 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to t
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the error c2664 cannot convert parameter from const char to lpcwstr workings and policies of this site About Us Learn more about Stack
Mfc Error C2664
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Error C2664 Cannot Convert Argument 1 From
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 http://stackoverflow.com/questions/25254938/c2664-error-c-visual-studio them; it only takes a minute: Sign up error C2664: cannot convert parameter 1 from 'X' to 'X' up vote 1 down vote favorite I have a C++/Win32/MFC project in Visual Studio 2008, and I'm getting a strange error message when I compile it. I've created a small project to demonstrate the problem, and the main code is #ifndef http://stackoverflow.com/questions/14713648/error-c2664-cannot-convert-parameter-1-from-x-to-x _MyObject_h #define _MyObject_h class MyObject { public: MyObject() { } }; #endif // _MyObject_h // --- END MyObject.h // --- BEGIN ObjectData.h #ifndef _ObjectData_h #define _ObjectData_h template 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 about Stack Overflow http://stackoverflow.com/questions/6678092/how-to-resolve-error-c2664-vswprintf-c-l-error-in-visual-studio-2005 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 http://www.scientificpsychic.com/blogentries/error-c2664-loadlibraryw-cannot-convert-parameter-to-lpcwstr.html of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to resolve error C2664 _vswprintf_c_l error in visual studio 2005? up vote 0 down vote favorite error c2664 The error shown: Error 11 error C2664: '_vswprintf_c_l' : cannot convert parameter 4 from 'void *' to '_locale_t' C:\Program Files\Microsoft Visual Studio 8\VC\include\swprintf.inl 41 It locates the file- C:\Program Files\Microsoft Visual Studio 8\VC\include\swprintf.inl which is a system file I guess. So, how to resolve? Platform: Visual Studio 2005 Version 8.0.50727.762 c visual-studio-2005 compiler-errors c2664 share|improve this question edited Jul 13 '11 at 14:15 asked Jul 13 '11 at 11:23 Gulshan 85211230 error c2664 cannot It sounds like you are forgetting to pass the locale parameter. –leppie Jul 13 '11 at 12:09 Is this the complete error message? The mistake is probably in your code. Could you please add the code where the error occurs. If VS doesn't point you to the specific line in your code, it must be in the file that's being compiled someplace where you call vswprintf or a similar function. –Codo Jul 13 '11 at 14:33 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote I've also seen this issue in a code I was dealing with. The problem was that stdlib.h was being included after a local header which probably was including some other c or c++ header. wrong order: #include "someheaderofmine.h"//includes several other headers #include Verbs Diet Index 2010-03-28 Error C2664 LoadLibraryW cannot convert parameter to LPCWSTR I recently used Microsoft Visual Studio 2008 to write a simple program to load a dynamic link library (DLL) module and invoke some of its entry points. I did not expect to get the error message C2664 from the simple LoadLibrary statement:HINSTANCE hinstLib = LoadLibrary("azspellaid.dll"); Error C2664: 'LoadLibraryW': cannot convert parameter 1 from 'const char [15]' to 'LPCWSTR' There are two ways of fixing this problem. The first one is to cast the quoted string with a Long Pointer to Const Wide String (LPCWSTR):HINSTANCE hinstLib = LoadLibrary((LPCWSTR)L"azspellaid.dll"); The C2664 error can also be resolved by keeping the original code and changing the character set of the project defaults from "unicode character set" to "multi-byte character set" as shown in this image: © Copyright2012 - Antonio Zamora