Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.UUCP Newsgroups: comp.lang.c Subject: Re: volatile question Message-ID: <464@haddock.UUCP> Date: Tue, 28-Apr-87 13:06:25 EDT Article-I.D.: haddock.464 Posted: Tue Apr 28 13:06:25 1987 Date-Received: Wed, 29-Apr-87 05:49:54 EDT References: <7124@brl-adm.ARPA> Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer) Organization: Interactive Systems, Boston Lines: 19 In article <7124@brl-adm.ARPA> rbbb@rice.EDU (David Chase) writes: >How does one make the distinction (in C, as proposed by ANSI) between "a >volatile pointer to something" and "a pointer to volatile something"? An >example of a pointer to a volatile is the address of a memory-mapped >device register; an example of a volatile pointer is an extern referenced >in a signal handler. I believe the former is "something * volatile foo" whereas the latter is "volatile something * foo". The same syntactic distinction is made for the "const" attribute. I think it looks ugly and confusing. (But I used to have trouble with prefix/postfix ++ when I was learning C, and I got that straight; maybe this is no worse.) In a program I wrote yesterday, I needed a pointer to a volatile pointer to char. (The pointer resided in shared memory, its referent did not.) This would seem to require "char * volatile * foo". I think "typedef char *str; volatile str * foo" should have worked too, but the compiler didn't like it. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint