Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!genrad!decvax!minow From: minow@decvax.UUCP (Martin Minow) Newsgroups: comp.lang.c Subject: Re: #define CTRL(x) followup (it can be done in ANSI C) Message-ID: <103@decvax.UUCP> Date: Mon, 24-Nov-86 19:58:14 EST Article-I.D.: decvax.103 Posted: Mon Nov 24 19:58:14 1986 Date-Received: Mon, 24-Nov-86 23:54:06 EST References: <7136@elsie.UUCP> <779@valid.UUCP> <5396@brl-smoke.ARPA> <560@mcgill-vision.UUCP> Reply-To: minow@decvax.UUCP (Martin Minow) Organization: Ultrix Eng. Group - Merrimack, NH Lines: 40 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 (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