• entries
101
122
• views
58296

# Towers of Hanoi

319 views

After a brief discussion about the portability of #pragma on the gamedev irc channel I did some research and discovered the following code in gcc. Here's the relevant part:

#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.  */static intdo_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

Apparently really old versions of gcc did something rather unexpected when it ran into a #pragma. While this makes me laugh, it's really inappropriate that a compiler would attempt to open a Towers of Hannoi game in emacs.

And in related madness, since i'm showing this code, i'm fairly certain I legally have to include the following message
Quote:
 This program is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation; either version 2, or (at your option) anylater version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.

meh, write the FSF - i'm too lazy to also distribute the full text of the GPL along with this code [wink]

There are no comments to display.

## Create an account

Register a new account