bammi@cwruecmp.UUCP (08/17/86)
I came across the following bug in Megamax C's pre-processor. It does not
substitute arguments enclosed in single quotes ('x'). My understanding
is that the pre-processor should not substitute arguements in strings
(ie within double quotes (")).
For Example:
#include <stdio.h>
#define BROKEN(x) putc('x', stdout); putc('\n', stdout)
main()
{
BROKEN(A);
}
will always print the character x no matter what the argument to BROKEN is.
Alcyon (v 4.14) and Vax (bsd 4.3) print out the character A as i expect.
--
Jwahar R. Bammi
Usenet: .....!decvax!cwruecmp!bammi
CSnet: bammi@case Arpa: bammi%case@csnet-relay
CompuServe: 71515,155
hugh@hcrvx1.UUCP (Hugh Redelmeier) (08/21/86)
In article <1557@cwruecmp.UUCP> bammi@cwruecmp.UUCP (Jwahar R. Bammi) writes: > >I came across the following bug in Megamax C's pre-processor. It does not >substitute arguments enclosed in single quotes ('x'). My understanding >is that the pre-processor should not substitute arguements in strings >(ie within double quotes (")). > >For Example: >#define BROKEN(x) putc('x', stdout); putc('\n', stdout) > BROKEN(A); >will always print the character x no matter what the argument to BROKEN is. >Alcyon (v 4.14) and Vax (bsd 4.3) print out the character A as i expect. A compiler that substitutes for parameters within either kind of quote will violate the current working draft of the X3J11 committee of ANSI. The Reiser pre-processor (used in most UNIX systems) does do this substitution. It is safest not to write anything that would be treated differently by these interpretations. Hugh Redelmeier (416) 922-1937 {utzoo, ihnp4, decvax}!hcr!hugh