🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #822

Re: What is a constant expression

#822
From: David Goodenough
Date: Fri, 20 Oct 1989 17:46
35 lines
1370 bytes
From article <1219@crdos1.crd.ge.COM>, by davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr):
>   Background: large program, defines ASCII control characters with a
> macro as follows:
> 	#define CNTL(c) ('c' & 037)
> While this work fine with pcc, the ANSI preprocessor doesn't expand it.

This is:

1. Grotesque,

2. Workable.

Flame away if you wish, just try it first.

#define	prequote(x) 'x
#define postquote(x) x'

#define	CNTL(c) ((postquote(prequote(c))) & 0x1f)

CNTL(c)

Bletch :-/

MAJOR MAJOR PROBLEM - our C compiler (greenhills) likes the useages of
postquote and prequote in that order. Some compilers may not care, while
others might want them reversed. I think it depends on whether nested
macros are expanded from the inside out (as Greenhills does), or outside
in.

It's probably not portable .... Oh well.
-- 
	dg@lakart.UUCP - David Goodenough		+---+
						IHS	| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp@xait.xerox.com			  +---+
Technical Details
Message-ID: <727@lakart.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ginosko!ctrsol!cica!tut.cis.ohio-state.edu!att!ima!cfisun!lakart!dg
References: <1219@crdos1.crd.ge.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ginosko!ctrsol!cica!tut.cis.ohio-state.edu!att!ima!cfisun!lakart!dg
From: dg@lakart.UUCP (David Goodenough)
Newsgroups: comp.std.c
Subject: Re: What is a constant expression
Message-ID: <727@lakart.UUCP>
Date: 20 Oct 89 17:46:23 GMT
References: <1219@crdos1.crd.ge.COM>
Organization: Lakart Corporation, Newton, MA
Lines: 26