Path: utzoo!attcan!uunet!cs.utexas.edu!uwm.edu!bionet!agate!shelby!neon!pescadero.Stanford.EDU!philip From: philip@pescadero.Stanford.EDU (Philip Machanick) Newsgroups: comp.lang.c++ Subject: Re: #defines.... Message-ID: <1990Jul2.164355.15327@Neon.Stanford.EDU> Date: 2 Jul 90 16:43:55 GMT References: <37786@genrad.UUCP> Sender: news@Neon.Stanford.EDU (USENET News System) Reply-To: philip@pescadero.stanford.edu Organization: Computer Science Department, Stanford University Lines: 20 In article <37786@genrad.UUCP>, slp@genrad.uucp (Steven L. Peters) writes: > Just out of curiousity... > > With the C++ const, enum, and inline declarations, is it ever > necessary to use #define in a C++ program? Stroustrup emphatically > says in _The C++ Programming Language_ not to use them if you don't > have to. I'm wondering if you ever have to. I can't think of a > single time where you would be forced to use a #define over const or > inline... > Just a small example... errno, which contains an error number from the most recent error (used in a number of common libraries) is defined as an integer _expression_. It can for example be implemented as a function call. Could the same effect be achieved with any of the new constructs? I think not, because function calls and variable references are syntactically different in C/C++ (unlike some other languages, where a parameterless function looks like a variable reference). Philip Machanick philip@pescadero.stanford.edu