🔒 Locked
compile errors with a .cpp that works
Advertisement
Original Post
I'm trying to develop a menu and GUI system for a game i'm working on. i decided to clean up the project and get rid of old test files by creating a new project and then copy/paste the .cpp file into the new folder. for some reason, despite using the same .cpp file (just copied the file itself into the folder) and spending an extremely long time checking every parameter in the properties window, i still get 5 errors: error C2664: 'D3DXCreateTextureFromFileExW' : cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast error C2664: 'D3DXCreateTextureFromFileExW' : cannot convert parameter 2 from 'const char [19]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast error C2440: 'initializing' : cannot convert from 'const char [9]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cas error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [9]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'const char [9]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast This doesn't make any sense. the program runs PERFECTLY in the first visual studio window. i move to the identical copy in the second window, nothing. i just get these errors, and i can't for a second think why.
Quote:
Original post by Palidine
not clear on the problem. Are you moving this file from Visual Studio to another IDE/compiler? Or did you copy/paste the file from one project to another?
Maybe there is some header included in Project A's pre-compiled header that is not present in the other project/IDE.
-me
same compiler. and i checked the linker (and every other setting in the properties section) the two are identical from what i can see.
Quote:
Original post by Malazar
and i checked the linker (and every other setting in the properties section) the two are identical from what i can see.
Files inserted into the PCH would not show up in the project settings. I'm not entirely sure what controls PCH stuff in visual studio (i think it's #pragma statements in the code... or maybe just the contents of stdafx.h). You could start by cross checking the contents of stdafx.h in both projects and making sure that all the same headers are #include'd
Otherwise, go to MSDN and find which header defines LPCWSTR and #include it into that .cpp file.
This is a compiler error by the way, not a linker error.
-me
Quote:
Original post by Palidine
Files inserted into the PCH would not show up in the project settings. I'm not entirely sure what controls PCH stuff in visual studio (i think it's #pragma statements in the code... or maybe just the contents of stdafx.h).
The overall PCH settings are in the project settings, but you just set one header file to turn into a PCH, and you must include that as the first thing you do in all source files (or rather, all source files that have that PCH setting; individual files can have separate properties don't forget). You then include whatever stuff you really want in that single header.
By default the header to use for PCH is stdafx.h though.
John B
Quote:
Original post by Wixner
cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR'
indicates that you are using the Unicode Character Set on one project and Multibyte Character Set on the other.
Change that or use Unicode (prefix 'L') strings in you project
right, that sounds like it upon reading further into it... however i don't know how to change between the two, where can i set the program to use multibyte (or vice versa)
Quote:Right-click on the project in the Solution Explorer (on the left of the source code window by default), and select Properties. Or if it's the startup (default) project, you can just hit Alt+F7.
Original post by Malazar Quote:
Original post by Wixner
cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR'
indicates that you are using the Unicode Character Set on one project and Multibyte Character Set on the other.
Change that or use Unicode (prefix 'L') strings in you project
right, that sounds like it upon reading further into it... however i don't know how to change between the two, where can i set the program to use multibyte (or vice versa)
Go to Configuration Properties -> General and change "Character Set" to "Use Multi-Byte Character Set", or "Use Unicode Character Set".
Quote:
Original post by Evil Steve Quote:Right-click on the project in the Solution Explorer (on the left of the source code window by default), and select Properties. Or if it's the startup (default) project, you can just hit Alt+F7.
Original post by Malazar Quote:
Original post by Wixner
cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR'
indicates that you are using the Unicode Character Set on one project and Multibyte Character Set on the other.
Change that or use Unicode (prefix 'L') strings in you project
right, that sounds like it upon reading further into it... however i don't know how to change between the two, where can i set the program to use multibyte (or vice versa)
Go to Configuration Properties -> General and change "Character Set" to "Use Multi-Byte Character Set", or "Use Unicode Character Set".
works now, thanks :D
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement