This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: coding style: type* variable or type *varible


----Original Message----
>From: Mike Stump
>Sent: 13 September 2005 20:28

> On Sep 13, 2005, at 12:23 PM, Rafael Espíndola wrote:
>> I have seen both in gcc. I have found that "type* variable" is
>> preferred in C++ code but I haven't found any guidelines for C code.
> 
> If you ask gcc, you find:
> 
> mrs $ grep 'int\* ' *.c | wc -l
>         4
> mrs $ grep 'int \*' *.c | wc -l
>       369
> 
> pretty clear to me.


  I was rather surprised, on reviewing the GNU coding standards, that it
doesn't actually mention this.  As far as I could find in a quick skim
through.  Perhaps it should.

  IMO (and this is a _very_ IMO subject, so I acknowledge in advance that
there is no one true way and that I may feel so but other people may feel
differently), the argument for making the asterisk abut the variable name
rather than the type is because the pointer-ness is indeed part of the
particular variable rather than of the type, and it can be summed up in one
simple question:

char* a, b, c;

  Why should we want a, b and c to look the same, when a is different from
the other two?
 
    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]