r/programminghorror • u/Mafla_2004 • Apr 30 '26
c Having fun with legacy C features :3

I found out about a couple old and obscure C features that somehow still work
This compiled and ran, printing just "This is fucky", though to get it to compile you have to compile using the following command
gcc -trigraphs -digraphs <your file>, on Windows at least
This is so cursed not even VSCode knew what I was doing
153
Upvotes
2
u/PearMyPie May 05 '26
you should have omitted main's return type as well.
84
u/ironykarl Apr 30 '26 edited May 01 '26
Trigraphs
and digraphshave thankfully been removed from C++, starting with C++17, and trigraphs (but not digraphs) were removed from C23.Uh... I guess I'm just sharing trivia, here ¯_(ツ)_/¯
EDIT: I went back to check. Digraphs are still supported in both C and C++ :-/
23
u/Solonotix May 01 '26
For those curious, I found this wonderful little blog on the page of digraphs and trigraphs.
https://blog.yossarian.net/2015/04/02/Digraphs-And-Trigraphs
Summary: In the olden times, keyboards may have lacked certain characters like curly braces. All of these uncommon characters were given a corresponding set of 2-3 common characters that would not normally appear in standard usage.
6
u/Interesting_Buy_3969 [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” May 02 '26
No one forces you to use trigraphs.. Except you if you're a masochist.
Yet trigraphs are no longer included in the C language after the C23 standard. I dont understand why people even recall those. Does someone seriously still have to deal with code from the 80's written on an exotic keyboard?..
There were many obsolete restrictions in the C language that were removed during its evolution. For example, your variables declarations were allowed to appear in the very beginning of a function only, or you get a compiler error otherwise. There were no one-line comments
// like this,/* and you could write only such comments */. And so on.-18
u/Blecki Apr 30 '26
How is this cursed?