On Feb 28 2004, Andras Erdei wrote:
[snip]
> type qualifiers always refer to the whole type to the left of them:
>
> char const * p means a pointer to a constant char (p=3D... ok, *p=3D... =
> not ok)
> char * const p means a constant pointer to a char (p=3D... not ok, =
> *p=3D... ok)
Thanks for the clarification. (-:
> as an exception to the above rule, type qualifiers are also allowed at
> the beginning of a type (when there's nothing left to them), and in this
> special case they modify the type right next to them, so "const int"
> is the same as "int const"
>
> compilers print qualified types in the first form, because they
> generate=20 it from some inner representation, and it's easier to always
> use the=20 general rule
>
> people have to write "char * const" because there is no alternative, but
> they often prefer "const char *" over "char const *", presumably out of
> tradition (?)
Yes, I think so. That is how K&R wrote it and how I have (almost) always
seen it written, at least in the kernel.
> >Anyway, normally I would write the qualified "const" first, then the =
> rest,=20
> >so I would write
> >
> >const char c;
> >const char *p;
> >const int i[20];
> >
> >etc... as that is how it is usually done in the kernel.
>
> i don't really care which one i have to use, but unless these conventions
> are written down somewhere, you'll have to flame me about every new line
> of code i write, because i will not know what you expect from me
True but I would just write the code. If nothing else we can always run
Lindent if we feel the need... (-; I suggest you just look at existing
libntfs code and try to stick more or less to the same notation and we
should be fine.
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
|