Wmain vs main C runtime

I read several articles about the different input positions of Windows C, wmain and WinMain.

So, if I am right, they are added to the C language compilers for Windows. But how are they implemented?

For example, wmain receives Unicode as argv [], but its Os, which sends these arguments to the program, is there also any special field in the .exe file entry that tells windows to pass arguments as unicode? Thank.

+3
source share
2 answers

Modern versions of Windows use UTF-16 internally. Therefore, when you run the executable, all command line arguments are most likely passed as UTF-16 from the very beginning, and the runtime library associated with the running application either passes arguments through fuzzy ones (if used wmain), or converts them to local encoding automatically (when using main). (In particular, this will be done using wmainCRTStartup/ mainCRTStartup, which are the entry points that are used for Windows console applications.)

+4
source

-: : wmain, , Unicode. Unicode - . wmain 16- Unicode, UTF-16 . Microsoft wmain , , Microsoft , Unicode, .

, . C , main/wmain/WinMain/wWinMain. main, , , .

+2
source

Source: https://habr.com/ru/post/1761273/


All Articles