bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: style question - const char *


From: Paul Eggert
Subject: Re: style question - const char *
Date: Thu, 17 Nov 2005 22:37:26 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Eric Blake <address@hidden> writes:

> Is there a preference for 'const char *' over 'char const *'?

I prefer putting type qualifiers like "const" after the types they
modify, as that's more consistent.  For example, "char * const *" puts
the "const" after the "char *", where it belongs.  Similarly,
"char const *" puts the "const" after the "char" -- also (I'd argue)
where it belongs.

Not everyone agrees with this style, but I suspect this is often
because they haven't thought through the consistency issues.  And it
is true that POSIX and C99 prefer "const" at the front rather than at
the logical place.  A pity.

If you want to mess with people's heads, you can use types like this:

   const int const long const signed const long const const const *

That's perfectly valid C, and it means the same thing as
"long long const *".  For a few more details, see
<http://www.cs.ucla.edu/classes/fall05/cs131/hw/hw5.html>.
(This was probably my least-popular assignment this quarter....)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]