Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site mcvax.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!guido From: guido@mcvax.UUCP (Guido van Rossum) Newsgroups: net.lang.c Subject: Re: Master listing of CPP symbols Message-ID: <6087@mcvax.UUCP> Date: Mon, 15-Oct-84 18:49:25 EDT Article-I.D.: mcvax.6087 Posted: Mon Oct 15 18:49:25 1984 Date-Received: Wed, 17-Oct-84 07:49:37 EDT References: <5056@root44.UUCP> Reply-To: guido@mcvax.UUCP (Guido van Rossum) Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam Lines: 77 Summary: Now that's the second compilation of predefined CPP symbols coming around this month. These symbols almost all seem to indicate particular hardware or software a program might be running on (exception: __FILE__ c.s.). I can't believe there is any program which checks for more than three or four of them (counterexamples to /dev/null, please). I suspect most people use them in a fashion like #ifdef MY_MACHINE ... Do some local tricks ... #endif or #ifndef MACHINE_X ... This doesn't work on machine X ... #endif or #ifdef SYSTEM_X ... Way to do it on sys X ... #else ... Way to do it somewhere else ... #endif Of course, this breaks when a program is spread to more that a few machines. What we really need here is something quite different: a set of #defines telling us what *features* are available on the target machine. (Note that the machine where the compiler runs is immaterial, unless it is a very buggy compiler.) So: #ifdef ETHERNET ... Collect and display info about net nodes ... #endif and #ifdef SELECT_SYSCALL ... Find out whether there's input pending ... #else ... Assume there is (or isn't) ... #endif I feel that, in the end, this is much more portable than using system names, where it will always be possible that a new system Z is a mixture of system X and system Y, thus necessitating a new #define although all the features are really nothing new. (I believe this is in fact already the case for many of the systems on the circulated lists.) (Aside: I've always wondered what use there was for Decus' "nomacargs". Either you can do the job without macro arguments; then do so, and you won't have to bother; or you can't, and then you're pretty helpless anyway when faced with the Decus compiler. But I shouldn't complain too loud, as it follows my proposal: #ifdef nomacargs is better than #ifdef DECUS.) Random shots at related topics: - #defined symbols should usually be recognizable by a convention line all uppercase (exception: getchar and such that must look like functions); - *pre*defined symbols should stand out even more because they may be there without the user knowing about them; perhaps __LINE__ and __FILE__ might set a standard (or the ANSI committee? :-) - it's nice if the ANSI standard finds a way out which makes things like 'unix' be defined and still evaluate to 'unix' by explicitly ruling out recursion; but have they thought about mutual recursion (#define a b; #define b a)? - I feel that "unix is on my side": during some stage of the development of the unix kernel, tests like #ifdef pdp111 were replaced by #ifdef UNIBUS etc. -- Guido van Rossum, "Stamp Out BASIC" Committee, CWI, Amsterdam guido@mcvax.UUCP "What was your mandoline doing in my bed?"