Path: utzoo!attcan!uunet!know!sdd.hp.com!uakari.primate.wisc.edu!uflorida!haven!mimsy!mojo!russotto From: russotto@eng.umd.edu (Matthew T. Russotto) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C Preprocessor Question Message-ID: <1990Oct25.175052.10355@eng.umd.edu> Date: 25 Oct 90 17:50:52 GMT References: <13065@crdgw1.crd.ge.com> Sender: news@eng.umd.edu (The News System) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 25 In article <13065@crdgw1.crd.ge.com> darweesh@zephyrus.crd.ge.com (Michael Darweesh) writes: >A simple question for those of you who know. Probably I should have posted >to a more general C board, but here it goes. > >Does the C preprocessor ever do any calculations or does it only do search >and replace? This question is very confusing and demands an example: > >#define foo 5 >#define bar 8 >#define baz ((foo * bar) >> 1) > >integer=baz; > >Basically, what I want to know is this... >Can I make the C preprocessor (specifically Think C) actually calculate >the value for baz at compile time? >I would like to be able to use this syntax to define baz as 20 instead of >((foo * bar) >> 1). The C preprocessor doesn't do any calculation, but the C compiler in many 'C's (including THINK, I think) will evaluate constant expressions at compile time, giving you the same effect. -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu Tax the rich, and feed the poor -- until there are, rich no more.