From: Joel Rosdahl Date: Thu, 1 Aug 2019 18:49:00 +0000 (+0200) Subject: Use #pragma once for guarding headers X-Git-Tag: v4.0~850 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77439a6f687913b39e4e37a148a51510b7c81c25;p=thirdparty%2Fccache.git Use #pragma once for guarding headers It seems to be supported by all reasonably modern compilers now. --- diff --git a/configure.ac b/configure.ac index f94781309..5321d2590 100644 --- a/configure.ac +++ b/configure.ac @@ -290,13 +290,12 @@ AC_CONFIG_FILES([Makefile]) AC_OUTPUT cat <config.h.tmp -#ifndef CCACHE_CONFIG_H -#define CCACHE_CONFIG_H +#pragma once #ifdef __clang__ -#pragma clang diagnostic push -#if __has_warning("-Wreserved-id-macro") -#pragma clang diagnostic ignored "-Wreserved-id-macro" -#endif +# pragma clang diagnostic push +# if __has_warning("-Wreserved-id-macro") +# pragma clang diagnostic ignored "-Wreserved-id-macro" +# endif #endif EOF @@ -304,9 +303,8 @@ cat config.h >>config.h.tmp cat <>config.h.tmp #ifdef __clang__ -#pragma clang diagnostic pop +# pragma clang diagnostic pop #endif -#endif // ifndef CCACHE_CONFIG_H EOF mv config.h.tmp config.h diff --git a/src/ccache.hpp b/src/ccache.hpp index 8e3f10f33..089f6b754 100644 --- a/src/ccache.hpp +++ b/src/ccache.hpp @@ -17,8 +17,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef CCACHE_H -#define CCACHE_H +#pragma once #include "system.hpp" #include "conf.hpp" @@ -325,5 +324,3 @@ void add_exe_ext_if_no_to_fullpath(char *full_path_win_ext, size_t max_size, #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif - -#endif // ifndef CCACHE_H diff --git a/src/common_header.hpp b/src/common_header.hpp index c131ee48d..05bcda40e 100644 --- a/src/common_header.hpp +++ b/src/common_header.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef COMMON_HEADER_H -#define COMMON_HEADER_H +#pragma once #include "compression.hpp" #include "third_party/xxhash.h" @@ -80,5 +79,3 @@ bool common_header_initialize_for_reading( char **errmsg); void common_header_dump(const struct common_header *header, FILE *f); - -#endif diff --git a/src/compopt.hpp b/src/compopt.hpp index 84a6c2f48..97157c976 100644 --- a/src/compopt.hpp +++ b/src/compopt.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2016 Joel Rosdahl and other contributors +// Copyright (C) 2010-2019 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef CCACHE_COMPOPT_H -#define CCACHE_COMPOPT_H +#pragma once #include "system.hpp" @@ -31,5 +30,3 @@ bool compopt_takes_arg(const char *option); bool compopt_takes_concat_arg(const char *option); bool compopt_prefix_affects_cpp(const char *option); bool compopt_prefix_affects_comp(const char *option); - -#endif // CCACHE_COMPOPT_H diff --git a/src/compression.hpp b/src/compression.hpp index 3cddb3de5..b48be1643 100644 --- a/src/compression.hpp +++ b/src/compression.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef COMPRESSION_H -#define COMPRESSION_H +#pragma once #include "system.hpp" #include "third_party/xxhash.h" @@ -93,5 +92,3 @@ enum compression_type compression_type_from_config(void); const char *compression_type_to_string(uint8_t type); struct compressor *compressor_from_type(uint8_t type); struct decompressor *decompressor_from_type(uint8_t type); - -#endif diff --git a/src/conf.hpp b/src/conf.hpp index 5fc408150..792d48a9b 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef CONF_H -#define CONF_H +#pragma once #include "system.hpp" @@ -73,5 +72,3 @@ bool conf_print_items(struct conf *conf, void (*printer)(const char *descr, const char *origin, void *context), void *context); - -#endif diff --git a/src/confitems.hpp b/src/confitems.hpp index 8505d0997..ae2f25344 100644 --- a/src/confitems.hpp +++ b/src/confitems.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef CONFITEMS_H -#define CONFITEMS_H +#pragma once #include "system.hpp" @@ -67,5 +66,3 @@ bool confitem_verify_dir_levels(const void *value, char **errmsg); const struct conf_item *confitems_get(const char *str, size_t len); size_t confitems_count(void); - -#endif diff --git a/src/counters.hpp b/src/counters.hpp index 746cc9788..43d334b60 100644 --- a/src/counters.hpp +++ b/src/counters.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2016 Joel Rosdahl and other contributors +// Copyright (C) 2010-2019 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef COUNTERS_H -#define COUNTERS_H +#pragma once #include @@ -30,5 +29,3 @@ struct counters { struct counters *counters_init(size_t initial_size); void counters_resize(struct counters *c, size_t new_size); void counters_free(struct counters *c); - -#endif diff --git a/src/envtoconfitems.hpp b/src/envtoconfitems.hpp index 8e5553c37..425e38f80 100644 --- a/src/envtoconfitems.hpp +++ b/src/envtoconfitems.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef ENVTOCONFITEMS_H -#define ENVTOCONFITEMS_H +#pragma once #include "system.hpp" @@ -29,5 +28,3 @@ struct env_to_conf_item { const struct env_to_conf_item *envtoconfitems_get(const char *str, size_t len); size_t envtoconfitems_count(void); - -#endif diff --git a/src/hash.hpp b/src/hash.hpp index 3f7f1eef9..eb341b2f6 100644 --- a/src/hash.hpp +++ b/src/hash.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef HASH_H -#define HASH_H +#pragma once #include "system.hpp" @@ -111,5 +110,3 @@ bool hash_fd(struct hash *hash, int fd); // // Returns true on success, otherwise false. bool hash_file(struct hash *hash, const char *fname); - -#endif diff --git a/src/hashutil.hpp b/src/hashutil.hpp index 083f9892f..3a270ac4b 100644 --- a/src/hashutil.hpp +++ b/src/hashutil.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef HASHUTIL_H -#define HASHUTIL_H +#pragma once #include "conf.hpp" #include "hash.hpp" @@ -42,5 +41,3 @@ bool hash_command_output(struct hash *hash, const char *command, const char *compiler); bool hash_multicommand_output(struct hash *hash, const char *command, const char *compiler); - -#endif diff --git a/src/language.hpp b/src/language.hpp index fb75c0aed..f119ece86 100644 --- a/src/language.hpp +++ b/src/language.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2016 Joel Rosdahl and other contributors +// Copyright (C) 2010-2019 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef CCACHE_LANGUAGE_H -#define CCACHE_LANGUAGE_H +#pragma once #include @@ -26,5 +25,3 @@ const char *p_language_for_language(const char *language); const char *extension_for_language(const char *language); bool language_is_supported(const char *language); bool language_is_preprocessed(const char *language); - -#endif // CCACHE_LANGUAGE_H diff --git a/src/macroskip.hpp b/src/macroskip.hpp index b580afb38..52a06b143 100644 --- a/src/macroskip.hpp +++ b/src/macroskip.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2016 Joel Rosdahl and other contributors +// Copyright (C) 2010-2019 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef CCACHE_MACROSKIP_H -#define CCACHE_MACROSKIP_H +#pragma once #include @@ -75,5 +74,3 @@ static const uint32_t macro_skip[] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, }; - -#endif diff --git a/src/manifest.hpp b/src/manifest.hpp index 7bbc7c127..4fe9e0c7f 100644 --- a/src/manifest.hpp +++ b/src/manifest.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef MANIFEST_H -#define MANIFEST_H +#pragma once #include "conf.hpp" #include "hashutil.hpp" @@ -30,5 +29,3 @@ struct digest *manifest_get(struct conf *conf, const char *manifest_path); bool manifest_put(const char *manifest_path, struct digest *result_digest, struct hashtable *included_files); bool manifest_dump(const char *manifest_path, FILE *stream); - -#endif diff --git a/src/result.hpp b/src/result.hpp index 8e059ef48..20212b60c 100644 --- a/src/result.hpp +++ b/src/result.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef RESULT_H -#define RESULT_H +#pragma once #include "conf.hpp" @@ -35,5 +34,3 @@ void result_files_free(struct result_files *c); bool result_get(const char *path, struct result_files *list); bool result_put(const char *path, struct result_files *list); bool result_dump(const char *path, FILE *stream); - -#endif diff --git a/src/system.hpp b/src/system.hpp index 2c1d6a0cb..72a98dbf9 100644 --- a/src/system.hpp +++ b/src/system.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef CCACHE_SYSTEM_H -#define CCACHE_SYSTEM_H +#pragma once #ifdef __MINGW32__ # define __USE_MINGW_ANSI_STDIO 1 @@ -91,5 +90,3 @@ extern "C" { #endif } // extern "C" - -#endif // CCACHE_SYSTEM_H diff --git a/src/unify.hpp b/src/unify.hpp index 4d0e53f48..eb6e6c4b7 100644 --- a/src/unify.hpp +++ b/src/unify.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Joel Rosdahl and other contributors +// Copyright (C) 2018-2019 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -16,11 +16,8 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef UNIFY_H -#define UNIFY_H +#pragma once #include "hash.hpp" int unify_hash(struct hash *hash, const char *fname, bool print); - -#endif diff --git a/unittest/framework.hpp b/unittest/framework.hpp index b812b5b5e..770344101 100644 --- a/unittest/framework.hpp +++ b/unittest/framework.hpp @@ -16,8 +16,7 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef TEST_FRAMEWORK_H -#define TEST_FRAMEWORK_H +#pragma once #include "../src/ccache.hpp" @@ -164,5 +163,3 @@ bool cct_check_args_eq(const char *file, int line, const char *expression, void cct_chdir(const char *path); void cct_wipe(const char *path); void cct_create_fresh_dir(const char *path); - -#endif diff --git a/unittest/util.hpp b/unittest/util.hpp index 7a62bae42..275b7c425 100644 --- a/unittest/util.hpp +++ b/unittest/util.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2018 Joel Rosdahl and other contributors +// Copyright (C) 2010-2019 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -16,13 +16,10 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef TEST_UTIL_H -#define TEST_UTIL_H +#pragma once #include bool path_exists(const char *path); bool is_symlink(const char *path); void create_file(const char *path, const char *content); - -#endif