hf_repo4 / src /test /probe_main.cpp
fava21's picture
Backup: patch pack applied + verified on Win11 22000 (d446cc1, ba8617e, dcf5cb8)
2edf277 verified
Raw History Blame Contribute Delete
1.63 kB
// FCS Glass - src/test/probe_main.cpp
//
// The console entry point for fcs_selftest (REQ sec 16).
//
// This lives in its own file rather than in platform.cpp for a concrete reason:
// platform.cpp is in FCS_CORE_SOURCES, which BOTH executables link. fcs_glass is
// a WIN32-subsystem app whose entry point is wWinMain (src/app/main.cpp), so a
// `main` in a shared translation unit would put a second entry point into the GUI
// binary. Keeping the probe's main separate means each target has exactly one.
//
// It had never been linked by CMake at all - every earlier M0a build supplied its
// own main() from a temporary harness - which is why the canonical build reported
// LNK2019 unresolved external `main`.
//
// COM is initialised here rather than inside the probe: apartment selection is a
// per-thread contract and does not carry to another thread, and the probe creates
// the D3D/DComp objects on this one. COINIT_APARTMENTTHREADED matches what the UI
// process wants (HC3/D-5: the UI is its own process and never a COM server).
#include "platform/platform.h"
#include <cstdio>
namespace fcs {
int ProbeMain(HINSTANCE instance); // defined in src/test/probe.cpp
} // namespace fcs
int main() {
fcs::ScopedCoInitialize com(COINIT_APARTMENTTHREADED);
if (!com.ok()) {
std::fprintf(stderr, "CoInitializeEx failed; the probe cannot run (hr=0x%08lX)\n",
static_cast<unsigned long>(com.hr()));
return 2;
}
// The probe's exit code is the scriptable result: 0 only when no row FAILed.
return fcs::ProbeMain(::GetModuleHandleW(nullptr));
}