Path: utzoo!news-server.csri.toronto.edu!rutgers!bellcore!uunet!mcsun!ukc!mucs!p4.cs.man.ac.uk!gilbertd From: gilbertd@p4.cs.man.ac.uk (Dave Gilbert) Newsgroups: comp.lang.c Subject: use of #ifndef machinetype Summary: dont use stuff like #ifndef msdos Keywords: pd portability C Message-ID: Date: 12 Mar 91 15:04:04 GMT Sender: news@cs.man.ac.uk Lines: 33 Hi, I'm presently porting a lot of PD C source to a machine which is neither UNIX or MSDOS (an Acorn Archimedes). What annoys me is when you have machine dependant chunks of code - obviously I dont mind #ifdef MSDOS do something - this is sensible. What I dont like is #ifNdef MSDOS - this presumes that every machine which is not MSDOS is UNIX (for example) - and as my machine well knows this is wrong. What I reckon is the best method is:- #ifdef UNIX unix blah #define gotmachine #endif #ifdef MSDOS MSDOS blah #define gotmachine #endif #ifndef gotmachine an obvious error { comment saying that it is not a known machine } #endif Or something to the same ends - dont presume a machine is either UNIX or MSDOS! Dave -- ------------------------------------------------------------------------------- - Dave Gilbert - gilbertd@p4.cs.man.ac.uk - The MTBF of a piece of equipment - - G7FHJ@GB7NWP - is inversly proportional to its - ------------------------------------------- importance -