A single-header C++ macro for printf-style debugging with colorized output, type info, and expression passthrough.
dbg-macro is a single-header C++ library that provides a `dbg(…)` macro for quick and informative runtime debugging. It prints values with context like file, line, and function names, along with type information, serving as a modern replacement for `printf` or `std::cout` debugging. The macro integrates seamlessly into expressions and outputs colorized results for easy readability.
C++ developers who need a fast, low-overhead way to inspect variables and expressions during development without setting up a full debugger. It's especially useful for those working in environments where interactive debuggers are impractical or time-consuming to configure.
Developers choose dbg-macro for its simplicity and rich output—it's a single header file with no dependencies, works across C++11/14/17, and provides more debugging context than basic print statements. Its expression-passthrough capability and automatic color handling make it both powerful and convenient for everyday debugging tasks.
A dbg(…) macro for C++
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically prints file name, line number, function name, and the original expression, making it easy to trace debug statements without manual formatting, as shown in the example output.
Includes type information and has specialized printers for containers, pointers, and enums, providing more insight than basic print statements, demonstrated in the README with vector and custom type examples.
Can be used inside expressions without altering behavior, returning the original value, which allows debugging without breaking apart complex code, as illustrated in the factorial example.
Consists of a single dbg.h file with no dependencies, making it trivial to integrate into any C++ project with minimal setup, supported by installation methods like copying or using package managers.
As a macro, it can have pitfalls with operator precedence or side effects in complex expressions, and it requires wrapping unprotected commas in parentheses, which adds complexity.
Only outputs values to stdout/stderr; lacks interactive features like breakpoints or memory inspection, limiting its use for deep debugging sessions compared to tools like GDB.
Adds runtime I/O overhead and issues compiler warnings to remind removal, which can be intrusive in builds that treat warnings as errors, requiring manual flag management.