Conversation
TrussC.h emits `#pragma comment(linker, "/subsystem:windows /entry:mainCRTStartup")` in every TU that includes it (Release, no TRUSSC_SHOW_CONSOLE). In a static- library object (core TrussC or an addon) that directive rides into the final link via the object's .drectve, and for /subsystem a .drectve overrides the command-line /SUBSYSTEM — so a single GUI-header-including addon (e.g. tcxWebSocket) silently turned a console tool into a GUI app that detaches from its launcher and survives its console window. Gate the pragma on !defined(TRUSSC_LIBRARY_TU) and define TRUSSC_LIBRARY_TU (PRIVATE) on the core lib and on every addon target (at the _tc_load_addon chokepoint, so it covers both own-CMakeLists and auto addons). The app's own TUs never get the define, so GUI apps still pin /subsystem:windows from their main TU. The subsystem is now decided solely by the app: GUI by default, console when it defines TRUSSC_SHOW_CONSOLE. Verified: anchorbolt links as Console (subsystem 3); a GUI graphics app still links as Windows (subsystem 2). Documented in ARCHITECTURE.md §3.5 and FOR_AI_ASSISTANT.md (console-app procedure).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows a TrussC console tool (e.g. anchorbolt) could link as the GUI subsystem instead of console, so it detached from
cmd(returned to the prompt immediately), ignoredCtrl+C, and kept running after its console window closed — while still printing nothing to the terminal.Root cause
TrussC.hemits#pragma comment(linker, "/subsystem:windows /entry:mainCRTStartup")in every TU that includes it (Release, noTRUSSC_SHOW_CONSOLE). In a static-library object (core TrussC, or an addon liketcxWebSocketthat includes<TrussC.h>) that directive rides into the final link via the object's.drectvesection — and for/subsystema.drectvedirective overrides the command-line/SUBSYSTEM. So one GUI-header-including addon flipped the whole image to GUI, and no command-line flag orlocal.cmakeworkaround could win.Fix
!defined(TRUSSC_LIBRARY_TU).TRUSSC_LIBRARY_TU(PRIVATE) on the coreTrussClib and on every addon target — applied at the_tc_load_addonchokepoint, so it covers both own-CMakeLists.txtaddons (viaadd_subdirectory) and auto addons.The app's own TUs never get the define, so GUI apps still pin
/subsystem:windowsfrom theirmainTU. The subsystem is now decided solely by the app: GUI by default, console when it definesTRUSSC_SHOW_CONSOLE.Verification (Windows, MSVC)
3Windows CUI2Windows GUIDocs
ARCHITECTURE.md§3.5 — new "Windows Subsystem: console tools vs GUI apps".FOR_AI_ASSISTANT.md— console-app creation procedure (defineTRUSSC_SHOW_CONSOLEinlocal.cmake; addons are handled automatically).Files:
core/include/TrussC.h,core/CMakeLists.txt,core/cmake/use_addon.cmake,docs/ARCHITECTURE.md,docs/FOR_AI_ASSISTANT.md.