type *var -- vs. -- type* var

johnathan.tainter tainter at cbnewsd.ATT.COM
Tue Sep 12 09:45:53 AEST 1989


In article <12813 at pur-ee.UUCP> lewie at ecn-ee.UUCP writes:
>Regarding declarations of pointers x, y and z, and question of why
>'int* x, y, z' doesn't do what's 'intuitive':
>>	(int *) x, y, z
>'(int *) x' is a cast, not a declaration.  Compiling the above yields
>errors about x, y and z being undeclared.  Because there's no explicit
>separator between declarations and statements, you'll never be able
>to declare pointers as such.  Isn't C syntax fun?

This is a place where typedef is not equivalent to a macro.

typedef int *Pointer_to_int;
Pointer_to_int x, y, z;

does exactly what was desired with only one side effect, it defines
a typedef.  Don't try and use a screwdriver as a chisel, especially when
you already have the chisel.

>Jeff Lewis (lewie at ee.ecn.purdue.edu, pur-ee!lewie)

--johnathan.a.tainter--
   att!ihlpb!tainter
   



More information about the Comp.lang.c mailing list