Expert C Programming

(Jeff_L) #1

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


And the corresponding source code in the preprocessor part of the compiler was:


/*


* 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");


}


Especially droll is the fact that the description in the user manual is wrong, in that the code shows that
"hack" is tried before "rogue".


Chapter 2. It's Not a Bug, It's a Language Feature


Bugs are by far the largest and most successful class of entity, with nearly a million known species. In
this respect they outnumber all the other known creatures about four to one.


—Professor Snopes' Encyclopedia of Animal Life


why language features matter...sins of commission: switches let you down with fall
through...available hardware is a crayon?...too much default visibility...sins of mission: overloading
the camel's back..."some of the operators have the wrong precedence"...the early bug gets() the
Internet worm...sins of omission: mail won't go to users with an "f" in their user name...space–the
final frontier...the compiler date is corrupted...lint should never have been separated out...some light
relief—some features really are bugs

Free download pdf