Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!dciem!nrcaer!cognos!jimp From: jimp@cognos.uucp (Jim Patterson) Newsgroups: comp.lang.c Subject: Re: Enum vs Define Message-ID: <1011@aldebaran.UUCP> Date: Mon, 29-Jun-87 10:59:02 EDT Article-I.D.: aldebara.1011 Posted: Mon Jun 29 10:59:02 1987 Date-Received: Wed, 1-Jul-87 04:24:58 EDT References: <196@dbase.UUCP> Reply-To: jimp@aldebaran.UUCP (Jim Patterson) Organization: Cognos Incorporated, Ottawa, Canada Lines: 25 In article <196@dbase.UUCP> awd@dbase.UUCP (Alastair Dallas) writes: >This may sound like a beginner's question, but I don't consider myself >a beginner: Why use enum instead of #define? It's often preferrable to use a language feature rather than a preprocessor featuure simply because the compiler can then make more intelligent decisions. This also extends to the language support systems such as debuggers. A good illustration of this is the VAX/VMS debugger which supports C as a high-level language. In your example, if you declare a value x as an enum and then in the debugger say EXAMINE x the debugger will give you an answer of ERRMSGA or ERRMSGB (assuming it contains a valid value). If you use #define, then the debugger will answer 1 or 2. Having the debugger provide symbolic answers instead of numeric ones can be a real benefit when you have a lot of such code and no handy listing. -- Jim Patterson decvax!utzoo!dciem!nrcaer!cognos!jimp Cognos Incorporated