码迷,mamicode.com
首页 > Windows程序 > 详细

(转) main(), _tmain(), wmain(), wWinMain(), _tWinMain()的区别

时间:2018-02-09 22:30:06      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:没有   clu   less   function   main   resolve   programs   就是   exe   

在C/C++编程中,最常见的就是main()函数,这是应用程序的入口,那么 _tmain(), wmain(), wWinMain(), _tWinMain()这些函数又是什么呢?
 
_tmain()是个宏,它需要头文件#include “stdafx.h”的支持,因为头文件stdafx.h中包含了头文件tchar.h,在头文件tchar.h里,微软做了以下宏定义

#ifdef  _UNICODE

#define _tmain      wmain

#define _tWinMain   wWinMain

 

也就是说,wmain()是UNICODE版本的main(), _tmain()是个宏,如果是UNICODE则它是wmain(),否则它是main(),wWinMain()与_tWinMain()的区别也相同;以下是msdn中关于这些函数的描述:

A special function named main is the starting point of execution for all C and C++ programs. If you are writing code that adheres to the Unicode programming model, you can use wmain, which is the wide-character version of main.

在所有C和C++程序中,以一个叫main的特殊函数作为应用程序的入口点,如果你希望在程序中使用Unicode 编码,那么你可以使用wmain,这是main函数的宽字符版本。

You can also use _tmain, which is defined in TCHAR.h. _tmain resolves to main unless _UNICODE is defined. In that case, _tmain resolves to wmain.

同时,我们可以使用_tmain,它在TCHAR.h头文件中定义,如果没有定义_UNICODE,那么_tmain会转换成mian,否则会被转换成wmain。

(转) main(), _tmain(), wmain(), wWinMain(), _tWinMain()的区别

标签:没有   clu   less   function   main   resolve   programs   就是   exe   

原文地址:https://www.cnblogs.com/lanzhizui/p/8436789.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!