Re: [PATCH v3 09/20] global: introduce `USE_THE_REPOSITORY_VARIABLE` macro

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Karthik Nayak <karthik.188@xxxxxxxxx> writes:
>
>>>> s/# define/#define/
>>>
>>> This is in fact intentional. We aren't strictly following this in our
>>> codebase, but when nesting preprocessor macros into ifdefs then we often
>>> indent the inner macros with spaces.
>>>
>>> Patrick
>>
>> That's something I didn't know. Thanks.
>
> Unlike borrowed sources in compat/, in our codebase, such
> indentation is minority.  IOW "often indent" -> "sometimes indent".
>
> A quick look at an early part of git-compat-util.h would show that
> even within a single file we are not consistent at all.
>
> #if __STDC_VERSION__ - 0 < 199901L
> #error "Required C99 support is in a test phase.  Please see git-compat-util.h for more details."
> #endif
>
> #ifdef USE_MSVC_CRTDBG
> #include <stdlib.h>
> #include <crtdbg.h>
> #endif
>
> #define _FILE_OFFSET_BITS 64
>
> #if defined(__GNUC__) && defined(__GNUC_MINOR__)
> # define GIT_GNUC_PREREQ(maj, min) \
> 	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
> #else
>  #define GIT_GNUC_PREREQ(maj, min) 0
> #endif
>
> #ifndef FLEX_ARRAY
> #if defined(__SUNPRO_C) && (__SUNPRO_C <= 0x580)
> #elif defined(__GNUC__)
> # if (__GNUC__ >= 3)
> #  define FLEX_ARRAY /* empty */
> # else
> #  define FLEX_ARRAY 0 /* older GNU extension */
> # endif
> #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
> # define FLEX_ARRAY /* empty */
> #endif
> ...
>
>
> We may want to eventually fix this, but we need to decide what the
> desirable layout is.  I am not sure if the indented version is
> easier to read and maintain, but one thing that is sure is that a
> mixed mess is harder than either.  In the above excerpt, you cannot
> tell if I quoted everything related to FLEX_ARRAY (in other words,
> if "#ifndef FLEX_ARRAY" is already closed in the excerpt) without
> carefully looking.

Perhaps putting the options next to each other is good way to think of
about the _desired layout_.

#ifndef FLEX_ARRAY
#if defined(__SUNPRO_C) && (__SUNPRO_C <= 0x580)
#elif defined(__GNUC__)
# if (__GNUC__ >= 3)
#  define FLEX_ARRAY /* empty */
# else
#  define FLEX_ARRAY 0 /* older GNU extension */
# endif
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define FLEX_ARRAY /* empty */
#endif

#ifndef FLEX_ARRAY
#if defined(__SUNPRO_C) && (__SUNPRO_C <= 0x580)
#elif defined(__GNUC__)
  #if (__GNUC__ >= 3)
    #define FLEX_ARRAY /* empty */
  #else
    #define FLEX_ARRAY 0 /* older GNU extension */
  #endif
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
  #define FLEX_ARRAY /* empty */
#endif

Somehow I feel the latter makes it a bit easier to grasp blocks, but
overall I think its more important that we pick one and perhaps add it
to 'Documentation/CodingGuidelines'.

Also, I did look at your response patch, but will leave it for someone
with perl experience to review.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux