August Derleth said:
As for GCC1 and `#pragma's: I guess I'm assuming that's a joke, but I
know odder things have happened in the world of software. And given
that GCC was a tool originally for the Unix-like GNU system (as
opposed to the UNIX-like Linux system), where you might reasonably
assume a rogue or nethack program to exist, well... could you at least
say `#pragma rogue' or `#pragma nethack' to control /which/ it would
launch?
Yes, it was a joke, but it really was implemented that way. It would
first try to run "rogue"; if that failed, it would try to run "hack";
if that failed, it would try to run GNU Emacs displaying the Towers of
Hanoi; if that failed, it would report a fatal error. (I think this
was before "nethack" existed.)
The C90 standard just says that #pragma "causes the implementation to
behave in an implementation-defined manner" (and that unrecognized
pragmas are ignored), so gcc's behavior was conforming, if odd.
Here's an excerpt from the oldest gcc sources I have, version 1.35,
released in 1989 (note the "#if 0"):
#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.
*/
do_pragma ()
{
close (0);
if (open ("/dev/tty", O_RDONLY, 0666) != 0)
goto nope;
close (1);
if (open ("/dev/tty", O_WRONLY, 0666) != 1)
goto nope;
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);
nope:
fatal ("You are in a maze of twisty compiler features, all different");
}
#endif
This version actually handled "#pragma once".
Newer versions of gcc are starting to do something very sensible. All
#pragmas are implemented as "#pragma GCC ..."; if you want to use
"#pragma GCC once", it's unlikely that another compiler will have
defined inconsistent semantics for it. Previously implemented pragmas
are still supported without the "GCC" prefix, but that form is
deprecated.