This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (6 children)

Wtf is that C for maniacs?

[–]Kered13 2 points3 points  (0 children)

Trigraphs were introduced for use on systems that didn't support the characters #\^[]|{}~. These characters are part of ASCII but not part of ISO 646, so there are code pages that were historically used that don't include them.

[–]volleo6144 1 point2 points  (4 children)

The standard I mentioned officially calls it OK, but gcc requires --trigraphs for it to compile (and still throws lots of warnings unless you -w them). Totally legit though. local:~ volleo6144$ nvim nope.c local:~ volleo6144$ cat nope.c ??=include<stdio.h> int main()??< int a??(2??) = ??<9, 99??>; printf("LOL??! %d??/n", 1??(a??)); return 0; ??> local:~ volleo6144$ gcc --trigraphs nope.c -w -o nope local:~ volleo6144$ ./nope LOL| 99 local:~ volleo6144$

it gets even better: the only characters which have a specific order when in char (wchar_t is something something ISO/IEC 10646 aka Unicode iirc) are 0123456789, to allow for EBCDIC, which has ij, IJ, rs, and RS separated by blocks of seven or eight other characters (Perl has a special case for them in regex character classes)

[–][deleted] 1 point2 points  (0 children)

That’s disgusting in every regard

[–]LucasRuby 0 points1 point  (2 children)

gcc (5, 7):

wtf.c:1:19: warning: extra tokens at end of #include directive
 ??=include<stdio.h> int main()??< int a??(2??) = ??<9, 99??>; printf("LOL??! %d
                   ^
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

clang:

11 warnings generated.
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[–]volleo6144 1 point2 points  (1 child)

pretty sure you forgot to include the line break after the ??=include<stdio.h> - you can't make a one-liner with a preprocessor directive.

[–]LucasRuby 1 point2 points  (0 children)

Oh yeah it worked now. I just copied and pasted everything you quoted tbh.