Show HN: Cdecl-dump - represent C declarations visually

Turns C’s code spaghetti into pictures — cue confusion, nostalgia, and hot takes

TLDR: A command-line tool visualizes confusing C code declarations but doesn’t strictly follow the language’s rules. Commenters split between bafflement at the screenshot and a throwback debate: ditch the dreaded “spiral rule” and use the simpler “declaration follows use,” questioning whether the visuals help or mislead.

A new Show HN drop, cdecl-dump, promises to turn C’s famously spaghetti-like declarations into visuals you can read on the command line. Think: transforming “unsigned char *const *arr[20][30]” into a diagram, so your brain doesn’t short-circuit. The catch? It only supports the language’s built‑in types, and the author admits it doesn’t strictly validate everything—meaning it cheerfully shows impossible combos like functions returning arrays. And that’s where the comments lit up.

First up, confusion: user coherentpony squinted at the README screenshot and basically said, “What am I looking at?” Meanwhile, veterans showed up with textbook trauma: pcfwik dropped links and wisdom, lamenting the infamous “spiral rule” (a loopy trick many were taught to decode C) and championing the simpler “declaration follows use” approach—aka write it how you’d use it, not how you’d untangle it. The hot debate: does this tool actually help, or does it paint pretty pictures of wrong ideas? Some joked the visuals look like “noodle charts” for a language that already serves enough ramen. Others reminisced about pointer war stories and declared the tool a neat demo, not a guidebook. Verdict? Fun toy, spicy comments, and a refresher course in how C got its reputation for brain knots.

Key Points

  • Cdecl-dump visualizes C declarations via the command line.
  • Usage examples include simple variables, functions, complex pointer arrays, and arrays of function pointers.
  • ./build.sh produces a debug build with parsing-stage tracing; DEBUG=0 ./build.sh produces an optimized executable.
  • The tool does not strictly enforce C validation and may allow invalid constructs (e.g., functions returning arrays, arrays of functions).
  • Only built-in C types are supported; typedef-based types like size_t and uint64_t are not accepted.

Hottest takes

“I don’t understand what the visualisation screenshot is trying to communicate to me” — coherentpony
“Misfortune of learning the so-called ‘spiral rule’ in college” — pcfwik
“‘Declaration follows use’ is the true philosophy behind C declaration syntax” — pcfwik
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.
Show HN: Cdecl-dump - represent C declarations visually - Weaving News | Weaving News