- Published on
TIL: Having a #pragma directive in your C code could launch a game!
The #pragma
is meant to allow the programmer to give hints to the compiler, which can then do "implementation-specific" things. Well, gcc
maintainers took this literally — on seeing this directive in a C
file, the compiler would stop compiling, and attempt to run a game!
The "#pragma" command is specified in the ANSI standard to have an arbitrary implementation- defined effect. In the GNU C preprocessor, "#pragma" first attempts to run the game "rogue"; if that fails, it tries to run the game "hack"; if that fails, it tries to run GNU Emacs displaying the Tower of Hanoi; if that fails, it reports a fatal error. In any case, preprocessing does not continue.
—Manual for version 1.34 of the GNU C compiler
Source: Expert C Programming: Deep Secrets, book by Peter van der Linden (it is a great read!)