From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: 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. --- runtime/doc/dev_style.txt | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/dev_style.txt b/runtime/doc/dev_style.txt index d6c465ef91..cb28f1a845 100644 --- a/runtime/doc/dev_style.txt +++ b/runtime/doc/dev_style.txt @@ -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___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 ~ -- cgit