[Spice-devel] [PATCH v3 09/11] Add mention of header guards

Frediano Ziglio fziglio at redhat.com
Fri Feb 9 09:55:54 UTC 2018


> 
> From: Christophe de Dinechin <dinechin at redhat.com>
> 
> Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
> ---
>  docs/spice_style.txt | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/docs/spice_style.txt b/docs/spice_style.txt
> index eb2ee252..ae91f987 100644
> --- a/docs/spice_style.txt
> +++ b/docs/spice_style.txt
> @@ -385,6 +385,25 @@ char *array[] = {
>      "item_3",
>  };
>  
> +Headers
> +-------
> +
> +Headers should be protected against multiple inclusion using a macro that
> contains the header file name in uppercase, with all characters that are
> invalid in C replaced with an underscore '_':
> +
> +[source,c]
> +---
> +#ifndef MY_MODULE_H
> +#define MY_MODULE_H
> +
> +...
> +
> +#endif // MY_MODULE_H
> +---
> +
> +The macro may include additional information, e.g. a component. For example
> a file generally referenced as foo/bar.h could use a FOO_BAR_H macro.
> +
> +Historically, some headers added underscores liberally, e.g. MY_MODULE_H_.
> This is neither necessary nor discouraged, although as a reminder, a leading
> underscore followed by a capital letter is reserved for the implementation
> and should not be used, so _MY_MODULE_H is, technically speaking, invalid C.
> +
>  Header inclusion
>  ----------------
>  

Acked-by: Frediano Ziglio <fziglio at redhat.com>

Frediano


More information about the Spice-devel mailing list