_tmain是main为了支持unicode所使用的main的别名 ._tmain()不过是unicode版本的的main().
<stdafx.h>中包含了
#include <stdio.h>
#include <tchar.h>
其中<tchar.h>里找到_tmain的宏定义
#define _tmain main
经过预编译以后, _tmain就变成main了
main()是标准C++的函数入口。默认字符编码格式ANSI (在简体中文Windows操作系统中,ANSI 编码代表 GBK 编码;在繁体中文Windows操作系统中,ANSI编码代表Big5;在日文Windows操作系统中,ANSI 编码代表 Shift_JIS 编码。)。
故Windows操作系统提供的对unicode字符集和ANSI字符集进行自动转换用的程序入口点函数
当你程序当前的字符集为unicode时,int _tmain(int argc, TCHAR *argv[])会被翻译成 int wmain(int argc, wchar_t *argv[])
当你程序当前的字符集为ANSI时,int _tmain(int argc, TCHAR *argv[])会被翻译成 int main(int argc, char *argv[])
原文地址:https://blog.youkuaiyun.com/zhangcancai/article/details/45168957
_tmain是main函数的Unicode版本别名,在C++中用于支持Unicode。当程序使用Unicode字符集时,_tmain会转化为wmain;若使用ANSI字符集,则转化为main。这一机制使得程序能够灵活地在不同字符集间切换。
1766

被折叠的 条评论
为什么被折叠?



