Visual Studio 2013 _tmain ?

Started by
1 comment, last by uglybdavis 9 years, 10 months ago

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?

Advertisement
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.

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

This topic is closed to new replies.

Advertisement