>#001p#"<>:#,_@#1-8*3:-1*57+55-1*79*57:-1:*77**278\-1:*57$p:1: error: declaration expected
Try it online!: Befunge-93, C
Thanks to randomdude999 for noting that the filename requires matching quotes to work.
Must be saved under the filename
\n is a newline. Because of this, the TIO for C doesn't run exactly as intended. Tested to work on Lubuntu.
The program fails to compile, and tcc happily outputs the name of the file as part of its error message. There are multiple compilation errors you can get, based on the beginning of the code.
^ at the start gives us a
declaration expected, which is short and doesn't contain any problematic characters like
". On the other hand, the gcc and clang developers are very pessimistic and they chose to output multiple errors at once, which is not very nice, so we aren't using their compilers.
Befunge is convenient for quines in that its code can also be utilised as character data, thanks to the
" command, which toggles string mode. At the beginning, we perform some useless stack operations, then issue a
p (put command) which places a NUL character at (0, 1). Then we reflect the instruction pointer to the left and begin reading everything as a string. This has to be done to the left, because of the stack's LIFO nature. After wrapping around and reaching the
" character again, the string ends. Note that the NUL character replaced the
$ character, creating a delimiter midway through the string. We then push 3 numbers onto the stack and jump over the NUL (because it unfortunately hangs the interpreter when run as an instruction). The static part of the error message has to be executed here. Most of its characters are no-ops, but the
p command consumes three arguments (hence why we pushed 3 numbers, otherwise part of the string would be eaten here), and
1 characters push a total of 4 values to the stack, which we counteract with a
p and a
$ (pop and discard) instruction. Then, some arithmetic is performed to push the ASCII codes for
^"\n>#001p#" and finally a loop prints out all the values on the stack as characters until it finds a NUL character and terminates.