In the MinGW compiler, what is the -mwindows command and what does it do?

I had a problem with a C ++ program where when I ran the .exe, the program started up and my window for the program would open, but the console would open on the desktop in the background. I did a google search and found that compiling with the -mwindows command as an argument removes the console. What did he do. But I'm not sure what this actually does, and I'm curious.

+3


source to share


2 answers


It says your application is being used using a Win32 API that doesn't need a console window. This option is used when writing Windows GUI applications, DLLs and the like, although the console window can be useful when debugging such applications. Even with this option, you can explicitly create a console window if your application needs to be dynamic, and conversely, you can call Win32 GUI APIs from a console application.



+4


source


It behaves exactly like the switch /subsystem:windows

described on MSDN
.

Basically, it sets the entry point WinMain

(or wWinMain

) instead of main

(or wmain

), which does not result in the absence of the console window and some Win32 startup code to create the arguments passed WinMain

. As Neal says, it doesn't prevent or allow anything that you can't do without.



A similar switch -municode

has to toggle between main

/ WinMain

and wmain

/ wWinMain

, which is not reflected by Microsoft tools. They seem to automatically pick the one you are using).

+3


source







All Articles