Header-only C and C++ library in the Pantheios.Extras namespace that aids diagnostics — notably memory-leak tracing around main().
Pantheios.Extras.DiagUtil is a small header-only library under the Pantheios extras namespace. It wraps a main()-like entry point so that, when compiling with Microsoft Visual C++ in _DEBUG, CRT memory allocations leaked by that call are reported via _CrtMemDumpAllObjectsSince. On other toolchains (and non-debug MSVC) the invoke path is a transparent passthrough.
That keeps application main() free of #if/crtdbg.h boilerplate while remaining compatible with the usual Extras nesting — for example wrapping Pantheios.Extras.Main and/or command-line helpers so leak tracing runs while the diagnostic logging layer is still initialised.
Hand-rolled CRT leak checkpoints in main() are noisy and easy to get wrong:
- You must remember conditional includes and checkpoints around every return path;
- Exception paths need an explicit dump before rethrow;
- Future backends (other compilers or leak detectors) would force every client to change;
Pantheios.Extras.DiagUtil centralises that protocol behind one C function and one C++ invoke overload set.
| Component | Implemented in | Use in | Dependencies |
|---|---|---|---|
| Core library | C / C++ headers | C — pantheios/extras/diagutil.h; C++ — …/diagutil.hpp | Pantheios, STLSoft |
| Examples | C / C++ | — | Pantheios, STLSoft |
| Tests | C | — | Pantheios, STLSoft, xTests |
Detailed instructions — via CMake, via bundling — are provided in the accompanying INSTALL.md file.
#include <pantheios/extras/diagutil.h>
int
pantheios_extras_diagutil_main_leak_trace_invoke(
int argc
, char** argv
, int (STLSOFT_CDECL* pfnMain)(int, char*[])
);#include <pantheios/extras/diagutil.hpp>
namespace pantheios {
namespace extras {
namespace diagutil {
namespace main_leak_trace {
int invoke(int argc, char** argv, int (STLSOFT_CDECL* pfnMain)(int, char*[]));
} // namespace main_leak_trace
} // namespace diagutil
} // namespace extras
} // namespace pantheiosExamples are provided in the examples directory (example.c.main_leak_trace.1, example.cpp.main_leak_trace.1).
Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/Pantheios.Extras.DiagUtil.
Pantheios.Extras.DiagUtil is released under the 3-clause BSD license. See LICENSE for details.