As I plow the digital seas, I often come across a piece of programming flotsam worthy of investigation. Most of it is obfuscated C, which is delightful. The obfuscated code that outputs something wonderful is most entertaining. But every so often I stumble upon something perplexing like the following code:
2026_07_18-Lesson.c
#include <stdio.h>
int typedef[[]]$;
int main($[[]]$)
{
[[]]$:&&$&&$&&puts("hello world");
return 0;
}
Seriously?
For starters, at Line 3, should typedef be the first item? What is int typedef? And then what is the typedef defining?
The code can build, but not under any circumstances, which I’ll get into shortly. Here is the output:
hello world
So, nothing fancy is going on other than code clutter that somehow doesn’t affect the puts() function — though it looks like it does.
First, this code does not build under clang:
0718.c:3:13: error: expected expression
int typedef[[]]$;
^
0718.c:5:12: error: expected expression
int main($[[]]$)
^
0718.c:5:15: error: expected ')'
int main($[[]]$)
^
0718.c:5:9: note: to match this '('
int main($[[]]$)
^
0718.c:5:11: warning: omitting the parameter name in a function definition is a C2x extension [-Wc2x-extensions]
int main($[[]]$)
^
0718.c:7:2: error: expected expression
[[]]$:&&$&&$&&puts("hello world");
^
1 warning and 4 errors generated.
The weird code builds under gcc with three warnings:
2026_07_18-Lesson.c:5:5: warning: ‘main’ takes only zero or two arguments [-Wmain]
5 | int main($[[]]$)
| ^~~~
2026_07_18-Lesson.c: In function ‘main’:
2026_07_18-Lesson.c:7:15: warning: the address of ‘$’ will always evaluate as ‘true’ [-Waddress]
7 | [[]]$:&&$&&$&&puts("hello world");
| ^~
2026_07_18-Lesson.c:7:21: warning: value computed is not used [-Wunused-value]
7 | [[]]$:&&$&&$&&puts("hello world");
|
All these warnings and errors make sense, until you accept the second item worth mentioning:
This code adheres to the C23 standard. Using the -std=c23 switch works for both clang and gcc.
To untie the knots, start with the typedef:
int typedef[[]]$;
The result of this statement is that the dollar sign is declared as an integer identifier: $ == int. Remember that the $ character isn’t used as an operator in C. But what’s happening here involves two tricky things.
The first is that [[]] is used as attribute syntax in the C23 standard. In a way, it works like an empty set of parentheses, so it’s ignored in the code (under C23).
The second thing happening is a quirk in the gcc compiler that accepts this type of backwards typedef definition. This exploit allows typedef to replace int as an identifier, though the result isn’t used elsewhere in the code. So, after all the dust settles, the $ identifier now means int
The main() function uses this as its argument: $[[]]$
In this obfuscation, the [[]] thing is ignored, so the declaration is $ of the type $. As main() has arguments by default, what’s captured here is the argc value, or integer count of items present at the command line, which is always a positive, non-zero value. The value is used in Line 7, which is also hideous:
[[]]$:&&$&&$&&puts("hello world");
The [[]] thing is ignored in C23 as an empty attribute.
$: is a label named $, which is the argument count from the main() function. As the label isn’t referenced, I think it’s just here for decoration and obfuscation.
The next few characters are parsed like this:
&&$ && $ &&
The &&$ is a gcc extension to obtain the address of a label, $.The result is an integer, not a pointer.
The && is a logical AND. It’s compared with $, which is the value of the main() function’s argument.
The final && evaluates the return value of the puts() function, which is non-negative. The entire expression evaluates as TRUE, though nothing acts upon this result.
Weird.
Bottom line: This code is obnoxiously obfuscated. It takes advantage of C23 as well as peculiarities with the gcc compiler. I avoid obfuscation in my code as much as possible, but I do take delight in unweaving puzzles such as this example.