#pragma in gcc
The ANSI C standard declares #pragma as implementation-defined. There is one small story, which I came across while reading the book, Deep C Secrets:
When the ANSI C standard was under development, the pragma directive was introduced. Borrowed from Ada, #pragma is used to convey hints to the compiler, such as the desire to expand a particular function as in-line or suppress some range checks. #pragma met with some initial resistancee from a gcc implementor, who took the "implementation-defined" effect very literally. In gcc version 1.34, the use of pragma caused the compiler to stop compiling and launch a computer game instead. The gcc version 1.34 manual said:
"The #pragma command is specified in the ANSI standard to have an arbitrary implementation-defined effect. In 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 Tower Of Hanoi; if that fails, it reports a fatal error. In any case, preprocessing does not continue."
Here's an excerpt from the gcc source, version 1.35, released in 1989 (note the "#if 0"):
/* This was a fun hack, but #pragma seems to start to be useful.
By failing to recognize it, we pass it through unchanged to cc1. */
* the behavior of the #pragma directive is implementation defined.
* this implementation defines it as follows.
if (open ("/dev/tty", O_RDONLY, 0666) != 0)
if (open ("/dev/tty", O_WRONLY, 0666) != 1)
execl ("/usr/games/hack", "#pragma", 0);
execl ("/usr/games/rogue", "#pragma", 0);
execl ("/usr/new/emacs", "-f", "hanoi", "9", "-kill", 0);
execl ("/usr/local/emacs", "-f", "hanoi", "9", "-kill", 0);
fatal ("You are in a maze of twisty compiler features, all different");
23 augustus 2007