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

来源:互联网 发布:lowspeed 编程 编辑:程序博客网 时间:2024/05/20 05:24
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.




0 0
原创粉丝点击