[Spice-devel] [spice-server] style: Slight tweak to the header guard section

Christophe de Dinechin cdupontd at redhat.com
Thu Feb 15 15:04:57 UTC 2018



> On 15 Feb 2018, at 15:55, Christophe Fergeau <cfergeau at redhat.com> wrote:
> 
> On Thu, Feb 15, 2018 at 03:25:23PM +0100, Christophe de Dinechin wrote:
>> 
>> 
>>> On 15 Feb 2018, at 13:41, Christophe Fergeau <cfergeau at redhat.com> wrote:
>>> 
>>> On Thu, Feb 15, 2018 at 11:55:44AM +0100, Christophe de Dinechin wrote:
>>>> Now, Christophe’s arguments are that
>>>> 
>>>> 1) we should not write guidelines that are inconsistent with existing code.
>>>> 2) this is in the server codebase, so we should server rules
>>>> 
>>>> Problem is with 2, really.
>>>> 
>>>> We started updating the guidelines because we wanted to talk about C++
>>>> style in the streaming agent, not the server.
>>>> I updated the server guidelines, because that’s historically where the
>>>> style guide has been, and the only place where SPICE has one.
>>>> 
>>>> For now, I’d vote for stating that the server guidelines apply to all
>>>> of the SPICE code. If we decide that means we should move them
>>>> elsewhere, that’s fine with me.
>>>> 
>>>> If that idea is accepted, then Christophe (2) no longer hold, and we
>>>> can explicitly state that we accept both // and /* for all comments,
>>>> including that one.
>>> 
>>> My patch was changing the example from using // to using /*,
>> 
>> That part I’m OK with.
>> 
>>> and was
>>> adding a note explicitly saying // was acceptable too.
>> 
>> That may have been your intent, but the way you wrote it was:
>> 
>> "C++ headers would use C++ comments."
>> 
>> This suggests that you can’t use // in C headers. Is that something we really want to enforce?
>> 
>> Again, I’d much prefer that we write somewhere that // or /* comments are both OK (not specifically for headers guards)
> 
> All I care about is that things stay mostly consistent within a given
> project. I don't want someone to come and say "oh but it's written in
> the coding style that I can use #endif // MY_MODULE_H!!" when the rest
> of the codebase is not using that.

Agreed. Worth adding, maybe as a general remark.

In my current staging area, I have near the beginning:

	This style guide only indicates what we aim to achieve. It does not necessarily reflect the current state of the code.

What about adding:

	Consistency matters. It may be preferable to ignore a style recommendation if it helps keeping the code style consistent.

And in the header part that you were adjusting, I’d be happy if you simply added:

+C++ headers guards should use // comments.
+The server consistently use /* */ comments for header guards




More information about the Spice-devel mailing list