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

Re: Clang-format configuration discussion - pt 1



On Mon, Nov 13, 2023 at 03:20:53PM +0000, Luca Fancellu wrote:
> 
> 
> > On 13 Nov 2023, at 11:31, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> > 
> > On 08.11.2023 10:53, Luca Fancellu wrote:
> > --------------------------------------------------------------------------------------------------------------------------------------------------------------
> >> 
> >> Standard: C++03
> >> 
> >> ---
> >> From the documentation: Parse and format C++ constructs compatible with 
> >> this standard.
> > 
> > Since I continue to be puzzled - iirc you said this is because of lack
> > of availability of "C99" as a value here. What's entirely unclear to
> > me is: How does this matter to a tool checking coding style (which is
> > largely about formatting, not any lexical or syntactical aspects)?
> > 
> >> This value is used also in Linux.
> > 
> > Considering how different the two styles are, I don't think this is
> > overly relevant.
On C it _shouldn't_ matter because it's meant to affect C++ constructs
only. That said, clang-format doesn't understand (or care) whether the code
is C or C++, because C's syntax is strictly contained in that of C++ as far
as formatting cares.

While I agree it feels wrong to apply a C++ policy to a C project, it's
largely irrelevant. Setting a value here gives more deterministic output
because it fixes several options' default settings. One would hope none of
those settings affect C, but the world is complex and it's better to be
safe than sorry. Particularly when it's an inocuous one-liner.

There aren't strict C values. And Latest or Auto are simply shorthands for
one of the C++ options.

  https://clang.llvm.org/docs/ClangFormatStyleOptions.html#standard

> 
> Ok, maybe I understand your point, you are looking for a reason to declare 
> this configurable instead
> of not specifying it at all?
> 
> If it’s that, from what I understand clang-format will use the default value 
> if we don’t specify anything
> for this one, so it will take ‘Latest’. I think we should put a value for 
> this one to fix it and don’t have
> surprises if that behaviour changes and seeing that also in Linux that value 
> is fixed increased my
> confidence.
> 
> However, if you feel that we should not specify it, I’ve done a test and not 
> specifying it is not changing
> the current output. I can’t say that for a different clang-format version 
> though or if changes happen in the
> future.
> 
IMO, C++03 is as good as any other. As long as it's a fixed one.

Cheers,
Alejandro



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.