Sign in to follow this  
Firecore

Compiler Error

Recommended Posts

Hi guys. Im using VC++ 2008 and Im learning how to make directx programs. When I compile my programs a funny thing happens. In a debug compilation, it works perfectly, but in the release compilation it refuses to compile and gives me errors: Does anyone know how to get rid of them and make the release work? Warning 1 Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release cl Asteroids Error 2 error C2664: 'D3DXCreateTextureFromFileW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\Terrain.cpp 27 Asteroids Error 3 error C2664: 'D3DXCreateTextureFromFileW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\Terrain.cpp 28 Asteroids Error 4 error C2664: 'D3DXCreateTextureFromFileW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\Terrain.cpp 29 Asteroids Error 5 error C2664: 'D3DXCreateTextureFromFileW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\Terrain.cpp 30 Asteroids Error 6 error C2664: 'D3DXCreateEffectFromFileW' : cannot convert parameter 2 from 'const char [11]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\Terrain.cpp 333 Asteroids Error 7 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\Terrain.cpp 335 Asteroids Error 8 error C2664: 'D3DXCreateTextureFromFileW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\PSystem.cpp 37 Asteroids Error 9 error C2664: 'D3DXCreateEffectFromFileW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\PSystem.cpp 42 Asteroids Error 10 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\PSystem.cpp 44 Asteroids Warning 11 warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\GfxStats.cpp 23 Asteroids Warning 12 warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\GfxStats.cpp 114 Asteroids Error 13 error C2664: 'ID3DXFont::DrawTextW' : cannot convert parameter 2 from 'char [256]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\GfxStats.cpp 117 Asteroids Error 14 error C2664: 'D3DXLoadMeshFromXW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dUtil.cpp 98 Asteroids Error 15 error C2664: 'D3DXCreateTextureFromFileW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dUtil.cpp 174 Asteroids Error 16 error C2440: '=' : cannot convert from 'const char [16]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dApp.cpp 64 Asteroids Error 17 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [21]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dApp.cpp 68 Asteroids Error 18 error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dApp.cpp 78 Asteroids Error 19 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [20]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dApp.cpp 82 Asteroids Error 20 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [23]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dApp.cpp 97 Asteroids Error 21 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [32]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\d3dApp.cpp 381 Asteroids Warning 22 warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\AsteroidsDemo.cpp 150 Asteroids Error 23 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [25]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\AsteroidsDemo.cpp 170 Asteroids Error 24 error C2664: 'D3DXCreateTextureFromFileW' : cannot convert parameter 2 from 'const char [13]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\AsteroidsDemo.cpp 206 Asteroids Error 25 error C2664: 'D3DXCreateEffectFromFileW' : cannot convert parameter 2 from 'const char [17]' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\AsteroidsDemo.cpp 443 Asteroids Error 26 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR' d:\C++\DirectX\A Shader Approach\Part III Ch 19-20\Chapter 20\Asteroids\AsteroidsDemo.cpp 445 Asteroids

Share this post


Link to post
Share on other sites
In VC 2005 this option was available under

Project Propertiers->Configurtation Properties->General->Character Set

which needs to be set to "Use Unicode Character Set" in your case. This should still be valid for VS 2008 (although I don't have it installed on this machine, so I can't check right now :().

Share this post


Link to post
Share on other sites
I just booted up VC2005:

Open up the properties page for your project. Then go to 'Configuration properties' / 'C/C++' / 'Preprocessor'.

Then add '; UNICODE' to your preprocessor definitions. (The edit field contains things like: 'WIN32;NDEBUG;' already, when viewed in Release mode.)

Share this post


Link to post
Share on other sites
Setting it to Unicode won't work since he's using plain old char's. So instead of setting the Character Set to Unicode you'll want to set it to... something other than Unicode.

Alternatively you can go in and change everything to use Unicode but that can be a bit of work.

Share this post


Link to post
Share on other sites
If you set your project to unicode, you'll need to use wide strings for everything (as in std::wstring instead of std::string). Use TCHARs instead of chars, and use existing macros to convert string literals to wide characters:

L"Unicode string";


Or, to not have to bother with any of this, set your project to use Multi-byte character set under Config->General->Character Set.

Share this post


Link to post
Share on other sites
From what I can see, you've got the character set in Debug mode set to "not set". In release mode, you've got it on "unicode" (which is default).

Set it to "not set" in the project pages, and make sure you're changing the release mode configuration.

Share this post


Link to post
Share on other sites
Configuration Properties -> General -> Character Set -> Use Multi Byte Character Set.

This is what i use in every project and with every string you have remove the L before it if you have any for example : L"somestring" -> "somestring"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this