Fish tank with Puck the Fish Fish tank with Puck the Fish Water on the floor spelling Fish
 

cdecl

November 12th, 2009

Quick, what is “char (*(*(* const x[3])())[5])(int)?”

If you immediately blurted out “x­is­an­array­of­three­const­pointers­to­functions­returning­pointers­to­arrays­of­five­pointers­to­functions­taking­int­returning­char“, and your last name doesn’t end with “itchie,” then chances are you used my new website:

www.cdecl.org

Yes, the venerable cdecl – the C gibberish to English translator – is now online. With AJAX! Every C declaration will be as an open book to you! Your coworkers’ scruffy beards and suspenders will be nigh useless!

Write C casts and declarations in plain English! Write plain English in the chicken scratchings and line noise we call C! The possibilities are twain!

(Click here to try it with that declaration!)

ANNNNND…it gets better! Did I mention that my version of cdecl supports blocks? That’s right, now you can totally nail that API that requires a block taking a pointer to a block taking a block taking a pointer to an int returning an int returning a pointer to a block taking void returning int!

This site:

  • Converts readable English variable declarations or typecasts to C
  • Converts C variable declarations or typecasts to English
  • Supports Apple’s blocks extension to C
  • Uses AJAX and has nifty effects
  • Allows you to generate permalinks, so you can send hilarious declarations to your friends, or add them gratuitously to your blog

A note on licensing. The cdecl readme states:

You may well be wondering what the status of cdecl is. So am I. It was twice posted to comp.sources.unix, but neither edition carried any mention of copyright. This version is derived from the second edition. I have no reason to believe there are any limitations on its use, and strongly believe it to be in the Public Domain.

I hereby place my blocks changes to cdecl in the public domain. The cdecl source code, including my changes, is available for download on the site.

 

The Internet!

π = 3.2860203432

Anonymous

I just wanted to leave some numbers!

Anonymous

What does this look like

Anonymous

Just wanted to try this out

Anonymous

π = 3!

Anonymous

the font is mall, but the numbers represent vast quantities

Anonymous

char (*(*(* const x[3])())[5])(int)

Anonymous

I just wanna help

Anonymous

keyboard: smashed.

Anonymous

Ques que fuck?

Anonymous

pi?

Anonymous

Hrmm – interesting concept, nice execution – what cases does it break down in?

Anonymous

leaving you numbers

Anonymous

Good job, old chap.

Anonymous

Sadly, … (ellipsis) for variable arguments doesn’t seem to work :(

Anonymous

it does not give syntax error to arrays of functions

Entered:
int f[10](char)

Get:
declare f as array 10 of function (char) returning int

Expected:
Syntax Error!! (Array type can not be function)

Anonymous

Syntax error for: int (^CountFrom(int start))(void)

Anonymous

int const * a;
syntax error??

Anonymous

WTF is a block?!

Now, if only that existed for English->Geek and Geek->English

Graham

I love cdecl, on and now offline, but it has some problems before it becomes a reliable tool. For example, there is nothing wrong with this declaration:
int const *p1;
Perhaps a future project could hook into LLVM’s clang++.

Graham

This should be fine too:
int (*ptr)[10];
but cdecl gives a syntax error.