Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!uwvax!dave From: dave@spool.wisc.edu (Dave Cohrs) Newsgroups: comp.unix.questions Subject: Re: Brain-dead Unix tutor needs quick help (-1) Message-ID: <4692@spool.wisc.edu> Date: Wed, 18-Nov-87 13:11:07 EST Article-I.D.: spool.4692 Posted: Wed Nov 18 13:11:07 1987 Date-Received: Sat, 21-Nov-87 08:09:52 EST References: <387@cogen.UUCP> Sender: news@spool.wisc.edu Reply-To: dave@spool.wisc.edu (Dave Cohrs) Organization: U of Wisconsin CS Dept Lines: 32 Summary: lack of parens cause parse errors In article <387@cogen.UUCP> alen@cogen.UUCP (Alen Shapiro) writes: >I've hit a mental >block about the reason ()s are used in preprocessor expressions like >#define XXX (-1). Consider this canned example: #define NEGATE -1 main() { int a; int b = 5; a=b NEGATE; printf("a should equal -5. a = %d\n", a); } If NEGATE were a variable, this would generate a loud "syntax error". But, because it's a #define, no error is generated, and the program behaves strangely (the programmer meant to put a "*" between b and NEGATE). If you say #define NEGATE (-1) You get the "syntax error" you wanted expected. Dave Cohrs +1 608 262-6617 UW-Madison Computer Sciences Department dave@cs.wisc.edu ...!{harvard,ihnp4,rutgers,ucbvax}!uwvax!dave