In article <[EMAIL PROTECTED]>,
Bakul Shah <[EMAIL PROTECTED]> wrote:
> [I see that jdp has answered your question but] cdecl is your friend!
>
> $ cdecl
> Type `help' or `?' for help
> cdecl> explain volatile struct timecounter *timecounter
> declare timecounter as pointer to volatile struct timecounter
> cdecl> declare timecounter as volatile pointer to struct timecounter
> struct timecounter * volatile timecounter
Is C a great language, or what? ;-)
The way I always remember it is that you read the declaration
inside-out: starting with the variable name and then heading toward
the outside while obeying the precedence rules. When you hit a "*",
you say "pointer to"; when you hit "[]", you say "array of"; and when
you hit "()" you say "function returning." For example:
struct timecounter * volatile timecounter;
/* "Timecounter is a volatile pointer to a struct timecounter." */
volatile struct timecounter *timecounter;
/* "Timecounter is a pointer to a struct timecounter which is volatile." */
The reason for the awkward "which is" in that last one is just because
C lets you get sloppy with the ordering of the outermost keywords.
The pedantically correct way to declare a pointer to volatile struct
is like this:
struct timecounter volatile *timecounter;
/* "Timecounter is a pointer to a volatile struct timecounter." */
John
--
John Polstra
John D. Polstra & Co., Inc. Seattle, Washington USA
"Disappointment is a good sign of basic intelligence." -- Ch�gyam Trungpa
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message