您的位置:首页 > 编程语言 > C语言/C++

C/C++ entry point: main, wmain, WinMain, wWinMain v.s. _UNICODE

2015-01-13 11:05 369 查看
Dev Env: In Microsoft Visual Studio C++ 2010

main() -
Console, ANSI;

wmain() -
Console, UNICODE;

WinMain() -
GUI, ANSI

wWinMain() - GUI, UNICODE

But note that Microsoft Visual studio C/C++ Project Wizard generated _tmain() and _tWinMain() for user and not any of above ones.

It's _tmain() for Console application;

It's _tWinMain() for GUI appliaction.

Actually _tmain and _tWinMain is macros which points to correct entry point function according to _UNICODE definition or not.

c:\program files (x86)\microsoft visual studio 10.0\vc\include\tchar.h

#ifdef _UNICODE

...

#define _tmain wmain

#define _tWinMain wWinMain

...

#else /* ndef _UNICODE */

#define _tmain main

#define _tWinMain WinMain

then the next question is - where _UNICODE macro is defined?

Project properties --> Configuration Properties --> General --> Project Defaults --> Character Set --> "Use Unicode Character Set"

with this setting, the compiler will defines _UNICODE macro before it begins compiling.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: