Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!samsung!uunet!mcsun!ukc!inmos!nathan@elberton.inmos.co.uk From: nathan@elberton.inmos.co.uk (Nathan Sidwell) Newsgroups: comp.lang.c Subject: Re: How to force cpp to abort? Message-ID: <9679@ganymede.inmos.co.uk> Date: 17 Aug 90 09:12:17 GMT References: Sender: rob@inmos.co.uk Reply-To: nathan@inmos.co.uk (Nathan Sidwell) Distribution: comp Organization: INMOS Limited, Bristol, UK. Lines: 56 In article mikeg@c3.c3.lanl.gov (Michael P. Gerlek) writes: > >I'm writing some machine dependent code... > >#if defined(__convex__) > (do Convex stuff) >#else >#if defined(cray) > (do Cray stuff) >#else >#if defined(sun) > (do Sun stuff) >#else > (oops) /* force abort */ >#endif >#endif >#endif > >[how to tidily abort compile at oops] You can use the #error preprocessor directive, viz #error Machine type not supported I would have emailed this, but it struck me that it also helps in another thread about array initializing. When I define an initialized array in a header file, and initialize it in the code file, the two must be kept in step. Ie "module.h" #define DETECTORS 7 extern char *detectors[DETECTORS] ; "module.c" #if DETECTORS != 7 #error Module assumes DETECTORS == 7 #endif extern char *detectors[DETECTORS] = { "Photomultiplier", "Silicon", "Raman", "Detector 3", "Detector 4", "Detector 5", "Detector 6", }; Much better than a comment telling me to keep them in step! Nathan Sidwell, INMOS Ltd, UK JANET: nathan@uk.co.inmos Generic disclaimer applies UUCP: ukc!inmos!nathan My indicision is final (I think) INTERNET: nathan@inmos.com