#define CTRL(x) followup (it can be done in ANSI C)
Martin Minow
minow at decvax.UUCP
Tue Nov 25 10:58:14 AEST 1986
According to what I have heard, the *latest* version of the C spec.
(i.e., the one "available for public comment") will permit CTRL(X)
as follows:
You must provide a header file such as
#define __A 001
#define __B 002
(etc.)
#define CTRL(X) __##X
Now, writing CTRL(A) expands to __A which is rescanned, recognized as
a macro, and expanded as 001. There are a few control characters
that can't be expanded this way, such as <CTRL/@> (NUL).
It should be pointed out that a better approach to this specific problem
would be
#define NUL '\000'
#define SOH '\001'
(etc.)
#define DEL '\177'
Then, the control characters will be functionally described.
As I understand the spec, Reiser constructions map into ANSI C as follows:
Reiser ANSI
token pasting: #define foo(a,b) a/**/b a##b
string repl.: #define foo(a) "xxx a yyy" "xxx #a yyy"
char repl.: #define foo(a) 'a' Not provided to my knowledge.
It should be pointed out that the Reiser constructions are not provided
in many non-Unix compilers, nor have they been well-documented and
formally specified.
Disclaimer: I am speaking for myself; and am neither a spokesman for
the ANSI committee nor for Dec.
Martin Minow
decvax!minow
More information about the Comp.lang.c
mailing list