TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: A set of dbg() macros for C

3 pointsby eerimoqover 5 years ago

1 comment

s_gourichonover 5 years ago
I wrote and use regularly similar macros for C, oriented towards minimal context.<p>They are less advanced on some areas, but more advanced on some.<p>For example, they do not depend on C11 generic feature, which is an advantage on the many non-C11 platforms (like 8-bit-targeting compiler SDCC).<p>On the strong side:<p>* log any expression: `somemacro(foo.bar())` will log `foo.bar() = 42` * compile-time global enable&#x2F;disable * compile-time debug level threshold<p>I&#x27;ve been planning to share that for a moment.<p>Some working parts are used on <a href="https:&#x2F;&#x2F;github.com&#x2F;cpcitor&#x2F;color-flood-for-amstrad-cpc&#x2F;blob&#x2F;master&#x2F;log.h" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cpcitor&#x2F;color-flood-for-amstrad-cpc&#x2F;blob&#x2F;...</a><p>It will eventually appear on <a href="https:&#x2F;&#x2F;github.com&#x2F;fidergo-stephane-gourichon?tab=repositories" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fidergo-stephane-gourichon?tab=repositori...</a><p>I also wrote similar macros for C++ mentioned on <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21071367" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21071367</a>