浅析_tmain() 与 main() 函数的区别
2015-10-13 10:30
507 查看
_tmain()是为了支持Unicode所使用的main的一个别名,既然是别名,应该有宏定义过的,在<stdafx.h>里
#include <stdio.h>
#indlude <tchar.h>
我们可以在<tchar.h>中找到_tmain()的宏定义
#define _tmain main
所以经过预编译后,_tmain就变成了main了。
main()是标准的C++的函数入口。标准C++程序入口点函数,默认字符编码格式为ANSI
函数签名为:
_tmain()是Windows提供的对Unicode字符集向ANSI字符集自动转换的程序入口点函数。
函数签名为:
当你的程序当前的字符集为Unicode时,int _tmain(int argc, TCHAR *argv[])会被翻译成 int wmian(int argc, wchar_t *argv[])
当你的程序当前的字符集为ANSI时,int _tmain(int argc, TCHAR *argv[])会被翻译成 int mian(int argc, char *argv[])
总之,int _tmain()函数是int main()函数的一个宏定义,当我们的字符集是Unicode时就应该使用int _tmain()。
参考文献:
[1] http://www.jb51.net/article/34516.htm
#include <stdio.h>
#indlude <tchar.h>
我们可以在<tchar.h>中找到_tmain()的宏定义
#define _tmain main
所以经过预编译后,_tmain就变成了main了。
main()是标准的C++的函数入口。标准C++程序入口点函数,默认字符编码格式为ANSI
函数签名为:
int main(); int main(int argc, char * argv[]);
_tmain()是Windows提供的对Unicode字符集向ANSI字符集自动转换的程序入口点函数。
函数签名为:
int _tmain(int argc, TCHAR *argv[]);
当你的程序当前的字符集为Unicode时,int _tmain(int argc, TCHAR *argv[])会被翻译成 int wmian(int argc, wchar_t *argv[])
当你的程序当前的字符集为ANSI时,int _tmain(int argc, TCHAR *argv[])会被翻译成 int mian(int argc, char *argv[])
总之,int _tmain()函数是int main()函数的一个宏定义,当我们的字符集是Unicode时就应该使用int _tmain()。
参考文献:
[1] http://www.jb51.net/article/34516.htm
相关文章推荐
- work daily
- head tail 命令
- HttpClient容易忽视的细节——连接关闭,使用不当服务器会出现大量的Close_Wait现象
- wait for fr result error, maybe timeout error
- Rails读书笔记第九章
- Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (k
- Rails读书笔记第七章
- charles 3.11对于cipher限制 Received fatal alert: handshake_failure
- Codeforces #325 D. Phillip and Trains (bfs)
- (中等) CF 585B Phillip and Trains,BFS。
- Codeforces Round #325 (Div. 2) Phillip and Trains dp
- LA 4064 Magnetic Train Tracks
- Maven 'failed to read artifact descriptor'
- LeetCode 11 Container With Most Water(最大水容器)
- 【高斯消元】poj 1681 Painter's Problem
- 【noip停课集训,10.12】【#2training】
- WebStorm 通过git取远端项目 cannot run program "git.exe" and Failed
- WebStorm 通过git取远端项目 cannot run program "git.exe" and Failed
- DataInputStream和DataOutputStream
- RAID4 慢的原因