[Spice-devel] [PATCH v2 11/13] Add mention of header guards

Frediano Ziglio fziglio at redhat.com
Thu Feb 8 08:58:46 UTC 2018


> 
> From: Christophe de Dinechin <dinechin at redhat.com>
> 
> Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
> ---
>  docs/spice_style.txt | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/docs/spice_style.txt b/docs/spice_style.txt
> index 780f0615..e2465aa9 100644
> --- a/docs/spice_style.txt
> +++ b/docs/spice_style.txt
> @@ -357,6 +357,21 @@ char *array[] = {
>      "item_3",
>  };
>  
> +Headers
> +-------
> +
> +Headers should be protected against multiple inclusion using a macro that
> matches the header file name in uppercase, with all characters that are
> invalid in C replaced with an underscore '_':

Maybe is just me, I'm reading this like: if name is foo.h the guard is
FOO_H. Which actually is not entirely true as should just contain the "FOO_H"
(for instance in public headers is better to include the project in some way).
Maybe is just my definition of "matches".

> +
> +[source,h]
> +---
> +#ifndef MY_MODULE_H
> +#define MY_MODULE_H
> +
> +...
> +
> +#endif /* MY_MODULE_H */
> +---
> +

Are we suggesting C style only comment or is clear the is not important?
(I'm just drinking my first coffee this morning)

>  Header inclusion
>  ----------------
>  

Frediano


More information about the Spice-devel mailing list