☰ Menu
Home›Command-line Tools›dbg-macro
CLI Open source 1 installs/mo

dbg-macro for Mac

dbg-macro

A macro for printf-style debugging fans.

dbg-macro — overview

dbg(…)

A macro for printf-style debugging fans.

Debuggers are great. But sometimes you just don't have the time or patience to set up everything correctly and just want a quick way to inspect some values at runtime.

This projects provides a single header file with a dbg(…) macro that can be used in all circumstances where you would typically write printf("…", …) or std::cout include include

// You can use "dbg(..)" in expressions: int32_t factorial(int32_t n) { if (dbg(n numbers{b, 13, 42}; dbg(numbers); // [example.cpp:21 (main)] numbers = {7, 13, 42} (std::vector)

dbg("this line is executed"); // [example.cpp:23 (main)] this line is executed

factorial(4);

return 0; } bash git clone https://github.com/sharkdp/dbg-macro sudo ln -s $(readlink -f dbg-macro/dbg.h) /usr/local/include/dbg.h bash yay -S dbg-macro bash vcpkg install dbg-macro cmake cmake_minimum_required(VERSION 3.11) # FetchContent added in cmake 3.11 project(app) # name of executable

set(CMAKE_CXX_STANDARD 17)

dbg-macro include(FetchContent)

FetchContent_Declare(dbg_macro GIT_REPOSITORY https://github.com/sharkdp/dbg-macro) FetchContent_MakeAvailable(dbg_macro)

add_executable(${PROJECT_NAME} main.cpp) # your source files goes here target_link_libraries(${PROJECT_NAME} PRIVATE dbg_macro) # make dbg.h available cpp include

int main() { dbg(42, "hello world", false); return 0; } c++ dbg(42, "hello world", false); c++ dbg("a vector:", (std::vector{2, 3, 4})); c++ const uint32_t secret = 12648430; dbg(dbg::hex(secret)); c++ template void my_function_template() { using MyDependentType = typename std::remove_reference::type&&; dbg(dbg::type()); } c++ dbg(dbg::time());

Development

If you want to contribute to dbg-macro, here is how you can build the tests and demos:

Make sure that the submodule(s) are up to date:

Then, use the typical cmake workflow. Usage of -DCMAKE_CXX_STANDARD=17 is optional, but recommended in order to have the largest set of features enabled:

To run the tests, simply call:

You can find the unit tests in tests/basic.cpp.

Acknowledgement

This project is inspired by Rusts dbg!(…)` macro.

Details

C语言的Dbg(…)宏

How to install dbg-macro

  1. Open Terminal (press ⌘ + Space and type “Terminal”).
  2. If Homebrew is not installed yet, run the command below first.
  3. Run this command:

Latest 10 releases

Last updated 2023-09-26; current version v0.5.1, with the latest 6 releases listed.

VersionReleasedTypeSizemacOSWindowsLinux
v0.5.12023-09-26Stable————
v0.5.02023-03-25Stable————
v0.4.02020-05-26Stable————
v0.3.02020-01-05Stable————
v0.2.12019-12-30Stable————
v0.2.02019-12-29Stable————

Data from GitHub Releases; stable releases first, each group sorted newest first.

Prebuilt bottle platforms

Official Homebrew bottles cover:

  • all

⚠️ No prebuilt bottle for Intel Macs; Intel users need brew install --build-from-source to build from source.

Compared with similar apps

Only public metadata is compared, with no subjective recommendation; see the compare pages for field-by-field comparisons.

Compared with similar apps
AppVersionLicenseArchitecture30-day installs
dbg-macrov0.5.1MITCLI1
dasmv2.20.18GPL-2.0-or-laterCLI13
tass641.60.3243GPL-2.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-only AND MITCLI20
m41.4.21GPL-3.0-or-laterCLI297

Similar apps: Command-line Tools

Leave a comment

评论表单加载中…