This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Function attributes indentation


Hi,

I'm not sure how to indent function attributes in headers: I've noted
some discrepancy the way they're indented.

For example, __THROW:

$ git grep -ho '^[[:space:]]*__THROW' -- '*.h' | sort | uniq -c | sort -nr
    637      __THROW                              # 5 spaces
     77 	__THROW                           # 1 tabular
     73    __THROW                                # 3 spaces
     52   __THROW                                 # 2 spaces
      7       __THROW                             # 6 spaces
      5 __THROW                                   #
      4     __THROW                               # 4 spaces
      3        __THROW                            # 7 spaces
      1 				  __THROW # 4 tabulars + 2 spaces

Sometimes thoses differences can be found in the same header, for
example:

  https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/spawn.h;h=471dbea02269;hb=5b06f538c5ae#l92

Another example, __attribute_ prefixed attributes (like
__attribute_malloc__, __attribute_pure__, __attribute_copy__, etc.):

$ git grep -ho '^[[:space:]]*__attribute_' -- '*.h' | sort | uniq -c | sort -nr
     94 __attribute_                             #
     94      __attribute_                        # 5 spaces
     40   __attribute_                           # 2 spaces
     25     __attribute_                         # 4 spaces
      5 	     __attribute_                # 1 tabular + 5 spaces
      5       __attribute_                       # 6 spaces
      3 	__attribute_                     # 1 tabular
      2 			__attribute_     # 3 tabulars
      2           __attribute_                   # 10 spaces
      1 			  __attribute_   # 3 tabulars + 2 spaces
      1 	 __attribute_                    # 1 tabular + 1 space
      1 	  __attribute_                   # 1 tabular + 2 spaces
      1 	    __attribute_                 # 1 tabular + 4 spaces
      1    __attribute_                          # 3 spaces
      1        __attribute_                      # 7 spaces
      1         __attribute_                     # 8 spaces

(In case of __attribute_ prefix, it appears in macro definitions, which
are not filtered out here, corrupting a bit the results).

I've found no mention of indentation rules for function attributes in 

  https://www.gnu.org/prep/standards/standards.html#Formatting
  https://sourceware.org/glibc/wiki/Style_and_Conventions

So what are the rules to apply to indent function attribute ?

It seems 5 spaces is the winner, but I would feel better if there would
be a rational behind this choice.

Regards.

-- 
Yann Droneaud
OPTEYA



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