Path: news1.icaen!news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!howland.erols.net!newsxfer2.itd.umich.edu!uunet!in3.uu.net!van-bc!news.mindlink.net!nntp.portal.ca!news.bc.net!rover.ucs.ualberta.ca!Myrias.AB.CA!eddore.myrias.com!eddore.myrias.com!not-for-mail From: gdr@eddore.myrias.com (Devin Reade) Newsgroups: comp.sys.apple2.programmer Subject: Orca/C v2.1 macro expansion bug Date: 24 Nov 1996 00:29:07 -0700 Organization: Myrias Research Corporation Lines: 38 Message-ID: <578tg3$v8@eddore.myrias.com> NNTP-Posting-Host: eddore.myrias.com Here's another problem to watch out for. In well written code it shouldn't be triggered, but this was in some legacy code I was working on. I've already forwarded this to Mike and Soenke. /* * This program demonstrates a problem with macros in Orca/C v2.1. * * This program incorrectly generates a compilation error because the * "ptr" parameter in FUNCTION() is being treated as "char *", as per * the typedef in . It _should_ be expanded to the actual * parameter first (in this example, "b"), since macro expansion is * supposed to occur _before_ tokenizing. * (Reference: ISO 9899-1990 art 5.1.1.2.) * * If "ptr" in the definition of FUNCTION is changed to "d" or some other * non-typedef, then this program compiles without error. * * Reported by Devin Reade , 24 Nov 96. */ #pragma lint -1 #pragma debug 25 #pragma keep "ptr" #include #include #define FUNCTION(c,ptr) strstr(c,ptr) char * strstr2 (char *a, char *b) { return FUNCTION(a,b); } -- The difference between science and the fuzzy subjects is that science requires reasoning, while those other subjects merely require scholarship. - Robert Heinlein