简体   繁体   中英

How to hide windows console in c++ tcc

How to hide console window, Compiler is tiny C

//Tiny C -> http://download.savannah.gnu.org/releases/tinycc/
#include <stdlib.h>
int main()
{
    system("Taskkill /IM test.exe /F");
    return 0;
}

When operating system starts application, it lookups special description table in EXE file called IMAGE_OPTIONAL_HEADER . This structure contains so called Subsystem field. When Subsystem is IMAGE_SUBSYSTEM_WINDOWS_CUI - OS attaches console window to this process. Otherwise, console window will not be added.

Compilers/linkers usually have parameters to set output application subsystem type, eg when you link your code using Microsoft Linker you can add /SUBSYSTEM:WINDOWS parameter and you will not see console window when starting your application.

The other way: compiler may automatically decide to set EXE subsystem to Console when seeing main function in your code, or set GUI subsystem when you have WinMain as entry point.

About TCC: I see -Wl,-subsystem=gui option in TCC documentation, but seems it is not worked. So try to send a bugreport or use more mature compiler/linker.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM