Jump to content
  • Advertisement
MarcusAseth

Redifine all string literals type in my program

This topic is 515 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering redifining all string literals in my program from "const char*" to "const wchar_t*" ? was feasable.

MessageBox(0, "Important stuff", 0, 0);

The code above is how my code looks, since I changed the project character set from Unicode to multybite character set.

If I hadn't, would look like this

	MessageBox(0, TEXT("Important stuff"), 0, 0);
	MessageBox(0, L"Important stuff", 0, 0);

And I don't like random L all over the place or extra typing trough TEXT(), that's why I'm not using Unicode right now, but I know I will need it in order to use kanjis, therefore I would like to be able to type 

MessageBox(0, "漢字禁止", 0, 0);

Without weird L or TEXT macro.

There is a way for me to instruct the compiler or whoever is that handle this stuff that all the literal strings in my program default to const wchar_t* instead of const char*? :S

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Advertisement

I wish. No, you will have to prefix everything with L. And don't bother using the TEXT macro at all, as it's pointless. Personally I explicitly call the W versions of Windows API functions - always MessageBoxW, never MessageBox. I am not on board with the macro horrors MS manufactured.

Share this post


Link to post
Share on other sites

that's a bummer x_x

I just tried and can't even #define w or W to be L... guess random L it is, then... x_x

Though what's the advantadge of calling MessageBoxW explicitly instead of MessageBox macro ? Is it a personal liking or something can actually go wrong? (In which case I wold like to know beforehand :D)

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
2 hours ago, MarcusAseth said:

Though what's the advantadge of calling MessageBoxW explicitly instead of MessageBox macro ? Is it a personal liking or something can actually go wrong? (In which case I wold like to know beforehand :D)

MessageBox(0, L"Whatever", 0, 0);

That requires UNICODE defined in the preprocessor to work correctly. Which is irritating. I want my code to build correctly with the minimum amount of configuration. Using the actual function name also has the added perk that Intellisense gives you an actual function declaration to work with.

Share this post


Link to post
Share on other sites

I personally prefer the A postfix functions over the macro choosen or unicode ones. I havent had anything that couldnt be used in plain ASCII/ANSI encoding yet

MessageBoxA(0, "Whatever", 0, 0);

 

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!