tmain(), wmain(), wWinMain(),

时间:2021-07-15 05:06:03

在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()的区别

标签:

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