• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Tim Lawton

"const wchar_t" is incompatible with parameter of type "LPCSTR"

10 posts in this topic

Hey there,

 

still fairly new to C++, having this issue in my code, as you can see from the screenshot

 

http://img203.imageshack.us/img203/8624/errorae.png

 

I know it might be something to do with MCBS and UNICODE strings, and that thing were you put an L before a quoted piece. But I'm unsure how to fix it.

 

fileNamePath is defined like this:

 

std::wstring fileNamePath;

 

If anyone could see what Im doing wrong Id be grateful! Thanks

0

Share this post


Link to post
Share on other sites

Oh the excitement of waiting for your massive png to load. Use code tags.

 

But yes, you need to compile your program with UNICODE defined (use unicode char set) in order to use wstring with DX. wstring::c_str returns a const wchar_t* which is LPCWSTR in windows speak, a LPCSTR is a const char* (so result of calling c_str on a std::string).

0

Share this post


Link to post
Share on other sites

Select Properties in the Project menu. Then, under Configuration Properties and General, change the parameter Character Set to Use Unicode Character Set.

1

Share this post


Link to post
Share on other sites

Select Properties in the Project menu. Then, under Configuration Properties and General, change the parameter Character Set to Use Unicode Character Set.

Thats fixed my related error, but has caused over 40 new errors.. Is there another way?

0

Share this post


Link to post
Share on other sites

You have two (sensical) solutions:

 

- Select "Unicode", then replace every std::string, LPCSTR, LPSTR etc.. in your project with the unicode-counterpart (std::wstring, LPCWSTR, LPWSTR). Also, you need to write an "L" before every string (e.g.:  L"C:/Pictures/Test.png"). This should fix your errors, if not, some of your other included libaries might be using multibyte, I'd get to that if his prooves to be the case.

 

- Keep your project at Multibyte setting, and replace every std::wstring, LPCWSTR, LPWSTR in your project with the multibyte-counterpart (I've already named those).

Edited by The King2
0

Share this post


Link to post
Share on other sites

You have two (sensical) solutions:

 

- Select "Unicode", then replace every std::string, LPCSTR, LPSTR etc.. in your project with the unicode-counterpart (std::wstring, LPCWSTR, LPWSTR). Also, you need to write an "L" before every string (e.g.:  L"C:/Pictures/Test.png"). This should fix your errors, if not, some of your other included libaries might be using multibyte, I'd get to that if his prooves to be the case.

 

- Keep your project at Multibyte setting, and replace every std::wstring, LPCWSTR, LPWSTR in your project with the multibyte-counterpart (I've already named those).

Yes this has fixed my related error, but now I have problems with certain operands such as this one:

 

error1qv.jpg

Other operands are now erroring as well, such as:

if(fileNamePath == texFileNameArray[i])
texFileNameArray.push_back(fileNamePath.c_str()); 

(the full stop before push_back)

std::string message = "Could not open: ";
			message += filename; 

 

So how do I get round this?

 

Thanks

0

Share this post


Link to post
Share on other sites

Sounds like your program simply isn't consistent with what character set it uses. Proper text handling of almost any kind is not trivial as soon as different encodings comes into play. It seems like your code consists of a mix of narrow and wide characters/strings, and mixing text encodings can be a real problem.

 

Decide on one single encoding for your entire program, and stick with it everywhere. If you need to handle text in different encodings, then make helper functions that converts text between the proper encoding and your program's encoding. But ultimately, your core program should not handle more than one encoding.

2

Share this post


Link to post
Share on other sites

Well this is all new and annoying, but thanks for the help either way... I think I'm going to set it to Unicode and change everything text based and slap an L before all quotes..

 

Thanks again

0

Share this post


Link to post
Share on other sites

There's a third option. If you only need to use Unicode (or ascii) versions of a handful of functions then you can call them directly by appending W (or A) to the function name.

 

For example the function GetGlyphOutline() is actually two functions. GetGlyphOutlineA() and GetGlyphOutlineW() and a define is set up depending on the Unicode setting to point to the right one. MSDN tells you that at the bottom of the documentation for the function. Only functions which work with text come in two versions like that.

 

That can be handy if you have lots of existing code that uses char * for things like file names, but want to add Unicode support for the user interface strings. Calling the right function explicitly lets you mix and match and avoid a lot of needless changes.

2

Share this post


Link to post
Share on other sites

Win32 is all in C. The typedefs LPCSTR and LPCWSTR are C-style strings. You can't really pass a std::string directly to functions that take this type. Pass it the result of std::string::c_str().

 

Also, Windows has the define TEXT that will automatically mark a string as with either L or not based on the defines of MBS or UNICODE.

0

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  
Followers 0