Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Visual Studio 2013 _tmain ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 uglybdavis   Members   -  Reputation: 963

Like
0Likes
Like

Posted 13 June 2014 - 10:23 PM

After several years of not using windows i find myself having to use visual studio 2013 (The last edition i used was visual studio 2008). To my surprise, my simple console application will not compile. It is complaining about a missing _tmain function. After checking out the default project that gets generated, i renames my main function from

 int main(int argc, char *argv[]) {

To

int _tmain(int argc, _TCHAR* argv[]) {

And everything now works...

 

When did this change happen?

What was the reasoning behind this? Why not just keep regular old main?

 

Is there any way to use the standard main function? I hate having #if statements just for windows....

 

Can anyone please shed some light on this matter for me?



Sponsor:

#2 frob   Moderators   -  Reputation: 22861

Like
7Likes
Like

Posted 13 June 2014 - 11:04 PM

It was all part of Microsoft's big plan to try to make code build as Unicode, or at least migrate away from single byte characters.

The _tchar and _txxxx variants are vendor-specific extensions, which is why they start with an initial underscore. They are automatically replaced with the right variation for single byte, multi byte, and Unicode text systems depending on which compiler switches you flip.


When you create a project look carefully through all the options, figure out the ones trying to make it unicode or multibyte aware, and turn those options off. Or you can do a bunch of reading to figure out how to use them properly, and then use _txxxx variants for everything in your code referring to strings, thereby confusing and annoying everybody else until you go back to the bad old formats of single byte characters.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#3 uglybdavis   Members   -  Reputation: 963

Like
1Likes
Like

Posted 14 June 2014 - 12:29 PM

Thank you! That is the exact info i needed!!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS