{"id":18913595,"url":"https://github.com/eerimoq/dbg-macro","last_synced_at":"2025-10-29T23:33:22.796Z","repository":{"id":64004851,"uuid":"210110142","full_name":"eerimoq/dbg-macro","owner":"eerimoq","description":"A set of dbg(…) macros for C","archived":false,"fork":false,"pushed_at":"2020-04-14T17:50:36.000Z","size":821,"stargazers_count":83,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T18:50:42.010Z","etag":null,"topics":["c","dbg","debug","macro"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eerimoq.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-22T07:49:49.000Z","updated_at":"2025-03-14T10:44:10.000Z","dependencies_parsed_at":"2022-11-30T13:50:48.624Z","dependency_job_id":null,"html_url":"https://github.com/eerimoq/dbg-macro","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eerimoq%2Fdbg-macro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eerimoq%2Fdbg-macro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eerimoq%2Fdbg-macro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eerimoq%2Fdbg-macro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eerimoq","download_url":"https://codeload.github.com/eerimoq/dbg-macro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249035308,"owners_count":21202057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","dbg","debug","macro"],"created_at":"2024-11-08T10:08:20.016Z","updated_at":"2025-10-29T23:33:22.718Z","avatar_url":"https://github.com/eerimoq.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"|buildstatus|_\n|codecov|_\n|nala|_\n\nAbout\n=====\n\nA few macros that prints and returns the value of a given expression\nfor quick and dirty debugging, inspired by Rusts `dbg!(…) macro`_ and\nits `C++ variant`_.\n\n``dbg(expr)`` for primitive data types (int, float, etc.), strings and\npointers.\n\n``dbgb(expr)`` to force boolean true/false output.\n\n``dbga(expr, length)`` for array of primitive data types.\n\n``dbgh(expr, size)`` for hexdump output.\n\n``dbge(expr)`` for negative error codes.\n\n``dbgbt()`` for a backtrace.\n\nJust include `dbg.h`_ in your project to use it.\n\nExample\n=======\n\n|tryit|_\n\nSee `examples`_ for the files used in this example.\n\n.. code-block:: c\n\n   #include \"dbg.h\"\n\n   static int factorial(int n)\n   {\n       if (dbgb(n \u003c= 1)) {\n           return dbg(1);\n       } else {\n           return dbg(n * factorial(n - 1));\n       }\n   }\n\n   int main()\n   {\n       char message[] = \"hello\";\n       dbg(message);  // main.c:15: message = \"hello\"\n       dbgh(message, sizeof(message));\n\n       const int a = 2;\n       const int b = dbg(3 * a) + 1;  // main.c:19: 3 * a = 6 (0x6)\n\n       int numbers[2] = { b, 13 };\n       dbga(numbers, 2);  // main.c:22: numbers = [7, 13] (length: 2)\n\n       dbg(factorial(4));\n       dbge(-EINVAL);\n       dbgbt();\n\n       return (0);\n   }\n\nBuild and run:\n\n.. image:: https://github.com/eerimoq/dbg-macro/raw/master/docs/example-build-and-run.png\n\nCompile time configuration\n==========================\n\nDefine ``NDBG`` to make the macros a no-op.\n\nDefine ``DBG_NCOLOR`` for colorless output.\n\nDefine ``DBG_OSTREAM=\u003cmy-ostream\u003e`` for custom output stream (stderr\nby default).\n\n.. |buildstatus| image:: https://travis-ci.org/eerimoq/dbg-macro.svg?branch=master\n.. _buildstatus: https://travis-ci.org/eerimoq/dbg-macro\n\n.. |codecov| image:: https://codecov.io/gh/eerimoq/dbg-macro/branch/master/graph/badge.svg\n.. _codecov: https://codecov.io/gh/eerimoq/dbg-macro\n\n.. |tryit| image:: https://img.shields.io/badge/try-online-f34b7d.svg\n.. _tryit: https://repl.it/@eerimoq/dbg-macro\n\n.. |nala| image:: https://img.shields.io/badge/nala-test-blue.svg\n.. _nala: https://github.com/eerimoq/nala\n\n.. _dbg!(…) macro: https://doc.rust-lang.org/std/macro.dbg.html\n\n.. _C++ variant: https://github.com/sharkdp/dbg-macro\n\n.. _dbg.h: https://github.com/eerimoq/dbg-macro/blob/master/include/dbg.h\n\n.. _examples: https://github.com/eerimoq/dbg-macro/tree/master/examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feerimoq%2Fdbg-macro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feerimoq%2Fdbg-macro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feerimoq%2Fdbg-macro/lists"}