refactor: replace manual header guards with #pragma once

It is less error-prone than manually defining header guards. Pretty much
all compilers support it even if it's not part of the C standard.
This commit is contained in:
dundargoc
2023-11-10 12:23:42 +01:00
committed by dundargoc
parent 353a4be7e8
commit 4f8941c1a5
220 changed files with 227 additions and 998 deletions

View File

@@ -32,19 +32,13 @@ but we nonetheless keep things as they are in order to preserve consistency.
Header Files *dev-style-header*
The #define Guard ~
Header guard ~
All header files should have `#define` guards to prevent multiple inclusion.
The format of the symbol name should be `NVIM_<DIRECTORY>_<FILE>_H`.
All header files should start with `#pragma once` to prevent multiple inclusion.
In foo/bar.h:
>c
#ifndef NVIM_FOO_BAR_H
#define NVIM_FOO_BAR_H
...
#endif // NVIM_FOO_BAR_H
#pragma once
<
@@ -245,15 +239,13 @@ contain only non-static function declarations. >c
// src/nvim/foo.h file
#ifndef NVIM_FOO_H
#define NVIM_FOO_H
#pragma once
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "foo.h.generated.h"
#endif
#endif // NVIM_FOO_H
64-bit Portability ~