From 5da067482aacef3bb8ba97d4c7cc2734fc49ba97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Langlois?= Date: Sun, 18 Nov 2018 19:20:21 +0100 Subject: [PATCH] fix: addition standard equivalent of "pragma once" Replacement of "pragma once" by its standard equivalent, to insure the compilation of the code by all compilers. --- include/spdlog/async_logger.h | 5 +++-- include/spdlog/common.h | 5 +++-- include/spdlog/contrib/sinks/step_file_sink.h | 4 +++- include/spdlog/details/async_log_helper.h | 4 +++- include/spdlog/details/async_logger_impl.h | 4 +++- include/spdlog/details/file_helper.h | 4 +++- include/spdlog/details/log_msg.h | 4 +++- include/spdlog/details/logger_impl.h | 4 +++- include/spdlog/details/mpmc_blocking_q.h | 6 ++++-- include/spdlog/details/null_mutex.h | 4 +++- include/spdlog/details/os.h | 5 ++++- include/spdlog/details/pattern_formatter_impl.h | 4 +++- include/spdlog/details/registry.h | 4 +++- include/spdlog/details/spdlog_impl.h | 4 +++- include/spdlog/formatter.h | 4 +++- include/spdlog/logger.h | 4 +++- include/spdlog/sinks/android_sink.h | 4 +++- include/spdlog/sinks/ansicolor_sink.h | 4 +++- include/spdlog/sinks/base_sink.h | 5 ++++- include/spdlog/sinks/dist_sink.h | 4 +++- include/spdlog/sinks/file_sinks.h | 4 +++- include/spdlog/sinks/msvc_sink.h | 4 +++- include/spdlog/sinks/null_sink.h | 4 +++- include/spdlog/sinks/ostream_sink.h | 4 +++- include/spdlog/sinks/sink.h | 4 +++- include/spdlog/sinks/stdout_sinks.h | 4 +++- include/spdlog/sinks/syslog_sink.h | 4 +++- include/spdlog/sinks/wincolor_sink.h | 4 +++- include/spdlog/sinks/windebug_sink.h | 4 +++- include/spdlog/spdlog.h | 4 +++- include/spdlog/tweakme.h | 4 +++- 31 files changed, 96 insertions(+), 34 deletions(-) diff --git a/include/spdlog/async_logger.h b/include/spdlog/async_logger.h index 75641d26..166e6150 100644 --- a/include/spdlog/async_logger.h +++ b/include/spdlog/async_logger.h @@ -2,8 +2,8 @@ // Copyright(c) 2015 Gabi Melman. // Distributed under the MIT License (http://opensource.org/licenses/MIT) // - -#pragma once +#ifndef ASYNC_LOGGER_H +#define ASYNC_LOGGER_H // Very fast asynchronous logger (millions of logs per second on an average desktop) // Uses pre allocated lockfree queue for maximum throughput even under large number of threads. @@ -70,3 +70,4 @@ private: } // namespace spdlog #include "details/async_logger_impl.h" +#endif diff --git a/include/spdlog/common.h b/include/spdlog/common.h index e02cb0bf..d61993b8 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -2,8 +2,8 @@ // Copyright(c) 2015 Gabi Melman. // Distributed under the MIT License (http://opensource.org/licenses/MIT) // - -#pragma once +#ifndef COMMON_H +#define COMMON_H #define SPDLOG_VERSION "0.17.0" @@ -186,3 +186,4 @@ using filename_t = std::string; _err_handler("Unknown exeption in logger"); \ } } // namespace spdlog +#endif diff --git a/include/spdlog/contrib/sinks/step_file_sink.h b/include/spdlog/contrib/sinks/step_file_sink.h index 85e24e95..b029bc2a 100644 --- a/include/spdlog/contrib/sinks/step_file_sink.h +++ b/include/spdlog/contrib/sinks/step_file_sink.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef STEP_FILE_SINK_H +#define STEP_FILE_SINK_H #include "../../details/file_helper.h" #include "../../details/null_mutex.h" @@ -214,3 +215,4 @@ using step_file_sink_st = step_file_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index 49789b94..cb0b43b0 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -10,7 +10,8 @@ // then the client call will block until there is more room. // -#pragma once +#ifndef ASYNC_LOG_HELPER_H +#define ASYNC_LOG_HELPER_H #include "../common.h" #include "../details/log_msg.h" @@ -331,3 +332,4 @@ inline void spdlog::details::async_log_helper::flush_sinks() } _last_flush = os::now(); } +#endif diff --git a/include/spdlog/details/async_logger_impl.h b/include/spdlog/details/async_logger_impl.h index 33ab4b90..bdb6ecb2 100644 --- a/include/spdlog/details/async_logger_impl.h +++ b/include/spdlog/details/async_logger_impl.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef ASYNC_LOGGER_IMPL_H +#define ASYNC_LOGGER_IMPL_H // Async Logger implementation // Use an async_sink (queue per logger) to perform the logging in a worker thread @@ -93,3 +94,4 @@ inline void spdlog::async_logger::_sink_it(details::log_msg &msg) throw; } } +#endif diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index d30a79b7..8111c6f1 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef FILE_HELPER_H +#define FILE_HELPER_H // Helper class for file sink // When failing to open a file, retry several times(5) with small delay between the tries(10 ms) @@ -149,3 +150,4 @@ private: }; } // namespace details } // namespace spdlog +#endif diff --git a/include/spdlog/details/log_msg.h b/include/spdlog/details/log_msg.h index 1d079aaf..406e7720 100644 --- a/include/spdlog/details/log_msg.h +++ b/include/spdlog/details/log_msg.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef LOG_MSG_H +#define LOG_MSG_H #include "../common.h" #include "../details/os.h" @@ -46,3 +47,4 @@ struct log_msg }; } // namespace details } // namespace spdlog +#endif diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index 084ecdd2..2e4d0fcd 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef LOGGER_IMPL_H +#define LOGGER_IMPL_H #include "../logger.h" @@ -346,3 +347,4 @@ inline const std::vector &spdlog::logger::sinks() const { return _sinks; } +#endif diff --git a/include/spdlog/details/mpmc_blocking_q.h b/include/spdlog/details/mpmc_blocking_q.h index d4a8a41c..95cf9f52 100644 --- a/include/spdlog/details/mpmc_blocking_q.h +++ b/include/spdlog/details/mpmc_blocking_q.h @@ -1,5 +1,3 @@ -#pragma once - // // Copyright(c) 2018 Gabi Melman. // Distributed under the MIT License (http://opensource.org/licenses/MIT) @@ -11,6 +9,9 @@ // enqueue_nowait(..) - will return immediatly with false if no room left in the queue // dequeue_for(..) - will block until the queue is not empty or timeout passed +#ifndef MPMC_BLOCKING_Q_H +#define MPMC_BLOCKING_Q_H + #include #include #include @@ -82,3 +83,4 @@ private: }; } // namespace details } // namespace spdlog +#endif diff --git a/include/spdlog/details/null_mutex.h b/include/spdlog/details/null_mutex.h index 3f495bd9..55612e13 100644 --- a/include/spdlog/details/null_mutex.h +++ b/include/spdlog/details/null_mutex.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef NULL_MUTEX_H +#define NULL_MUTEX_H #include // null, no cost dummy "mutex" and dummy "atomic" int @@ -43,3 +44,4 @@ struct null_atomic_int } // namespace details } // namespace spdlog +#endif diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 42f61581..4c1a2d3c 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -2,7 +2,9 @@ // Copyright(c) 2015 Gabi Melman. // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once + +#ifndef OS_H +#define OS_H #include "../common.h" @@ -429,3 +431,4 @@ inline bool in_terminal(FILE *file) } // namespace os } // namespace details } // namespace spdlog +#endif diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h index e3d70878..871275cf 100644 --- a/include/spdlog/details/pattern_formatter_impl.h +++ b/include/spdlog/details/pattern_formatter_impl.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef PATTERN_FORMATTER_IMPL_H +#define PATTERN_FORMATTER_IMPL_H #include "../details/log_msg.h" #include "../details/os.h" @@ -705,3 +706,4 @@ inline void spdlog::pattern_formatter::format(details::log_msg &msg) // write eol msg.formatted << _eol; } +#endif diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 614220d5..2c659a4b 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef REGISTRY_H +#define REGISTRY_H // Loggers registy of unique name->logger pointer // An attempt to create a logger with an already existing name will be ignored @@ -261,3 +262,4 @@ using registry = registry_t; } // namespace details } // namespace spdlog +#endif diff --git a/include/spdlog/details/spdlog_impl.h b/include/spdlog/details/spdlog_impl.h index 4c363834..0ebff14b 100644 --- a/include/spdlog/details/spdlog_impl.h +++ b/include/spdlog/details/spdlog_impl.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef SPDLOG_IMPL_H +#define SPDLOG_IMPL_H // // Global registry functions @@ -276,3 +277,4 @@ inline void spdlog::drop_all() { details::registry::instance().drop_all(); } +#endif diff --git a/include/spdlog/formatter.h b/include/spdlog/formatter.h index 55388ec5..01ac8102 100644 --- a/include/spdlog/formatter.h +++ b/include/spdlog/formatter.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef FORMATTER_H +#define FORMATTER_H #include "details/log_msg.h" @@ -44,3 +45,4 @@ private: } // namespace spdlog #include "details/pattern_formatter_impl.h" +#endif diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index aa4a2c5d..1c0bad7c 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef LOGGER_H +#define LOGGER_H // Thread safe logger (except for set_pattern(..), set_formatter(..) and set_error_handler()) // Has name, log level, vector of std::shared sink pointers and formatter @@ -150,3 +151,4 @@ protected: } // namespace spdlog #include "details/logger_impl.h" +#endif diff --git a/include/spdlog/sinks/android_sink.h b/include/spdlog/sinks/android_sink.h index dd811633..09522bf5 100644 --- a/include/spdlog/sinks/android_sink.h +++ b/include/spdlog/sinks/android_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef ANDROID_SINK_H +#define ANDROID_SINK_H #if defined(__ANDROID__) @@ -89,3 +90,4 @@ private: } // namespace spdlog #endif +#endif diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h index e74389c9..0f8fb515 100644 --- a/include/spdlog/sinks/ansicolor_sink.h +++ b/include/spdlog/sinks/ansicolor_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef ANSICOLOR_SINK_H +#define ANSICOLOR_SINK_H #include "../common.h" #include "../details/os.h" @@ -148,3 +149,4 @@ using ansicolor_stderr_sink_st = ansicolor_stderr_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/base_sink.h b/include/spdlog/sinks/base_sink.h index 96cd001e..cedab903 100644 --- a/include/spdlog/sinks/base_sink.h +++ b/include/spdlog/sinks/base_sink.h @@ -3,7 +3,9 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef BASE_SINK_H +#define BASE_SINK_H + // // base sink templated over a mutex (either dummy or real) // concrete implementation should only override the _sink_it method. @@ -47,3 +49,4 @@ protected: }; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/dist_sink.h b/include/spdlog/sinks/dist_sink.h index b4a7b6a1..ce5e6e82 100644 --- a/include/spdlog/sinks/dist_sink.h +++ b/include/spdlog/sinks/dist_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef DIST_SINK_H +#define DIST_SINK_H #include "../details/log_msg.h" #include "../details/null_mutex.h" @@ -75,3 +76,4 @@ using dist_sink_st = dist_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/file_sinks.h b/include/spdlog/sinks/file_sinks.h index 109c493a..13ba057f 100644 --- a/include/spdlog/sinks/file_sinks.h +++ b/include/spdlog/sinks/file_sinks.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef FILE_SINKS_H +#define FILE_SINKS_H #include "../details/file_helper.h" #include "../details/null_mutex.h" @@ -253,3 +254,4 @@ using daily_file_sink_st = daily_file_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/msvc_sink.h b/include/spdlog/sinks/msvc_sink.h index 09a5d671..d5dab562 100644 --- a/include/spdlog/sinks/msvc_sink.h +++ b/include/spdlog/sinks/msvc_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef MSVC_SINK_H +#define MSVC_SINK_H #if defined(_WIN32) @@ -42,3 +43,4 @@ using msvc_sink_st = msvc_sink; } // namespace spdlog #endif +#endif diff --git a/include/spdlog/sinks/null_sink.h b/include/spdlog/sinks/null_sink.h index c254bc59..d037ac7e 100644 --- a/include/spdlog/sinks/null_sink.h +++ b/include/spdlog/sinks/null_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef NULL_SINK_H +#define NULL_SINK_H #include "../details/null_mutex.h" #include "base_sink.h" @@ -27,3 +28,4 @@ using null_sink_st = null_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/ostream_sink.h b/include/spdlog/sinks/ostream_sink.h index 97281384..7b6e1bd8 100644 --- a/include/spdlog/sinks/ostream_sink.h +++ b/include/spdlog/sinks/ostream_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef OSTREAM_SINK_H +#define OSTREAM_SINK_H #include "../details/null_mutex.h" #include "base_sink.h" @@ -47,3 +48,4 @@ using ostream_sink_st = ostream_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/sink.h b/include/spdlog/sinks/sink.h index b4e38068..56889433 100644 --- a/include/spdlog/sinks/sink.h +++ b/include/spdlog/sinks/sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef SINK_H +#define SINK_H #include "../details/log_msg.h" @@ -42,3 +43,4 @@ inline level::level_enum sink::level() const } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/stdout_sinks.h b/include/spdlog/sinks/stdout_sinks.h index b15d0803..4ece8e8d 100644 --- a/include/spdlog/sinks/stdout_sinks.h +++ b/include/spdlog/sinks/stdout_sinks.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef STDOUT_SINKS_H +#define STDOUT_SINKS_H #include "../details/null_mutex.h" #include "base_sink.h" @@ -77,3 +78,4 @@ using stderr_sink_st = stderr_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index 17bbb1df..a090e1aa 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef SYSLOG_SINK_H +#define SYSLOG_SINK_H #include "../common.h" @@ -74,3 +75,4 @@ private: } // namespace spdlog #endif +#endif diff --git a/include/spdlog/sinks/wincolor_sink.h b/include/spdlog/sinks/wincolor_sink.h index 402fa121..ea5505f4 100644 --- a/include/spdlog/sinks/wincolor_sink.h +++ b/include/spdlog/sinks/wincolor_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef WINCOLOR_SINK_H +#define WINCOLOR_SINK_H #include "../common.h" #include "../details/null_mutex.h" @@ -142,3 +143,4 @@ using wincolor_stderr_sink_st = wincolor_stderr_sink; } // namespace sinks } // namespace spdlog +#endif diff --git a/include/spdlog/sinks/windebug_sink.h b/include/spdlog/sinks/windebug_sink.h index 2c7f1bc2..f0e8f281 100644 --- a/include/spdlog/sinks/windebug_sink.h +++ b/include/spdlog/sinks/windebug_sink.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef WINDEBUG_SINK_H +#define WINDEBUG_SINK_H #if defined(_WIN32) @@ -25,3 +26,4 @@ using windebug_sink_st = msvc_sink_st; } // namespace spdlog #endif +#endif diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 21f5951b..4e4987ee 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -5,7 +5,8 @@ // spdlog main header file. // see example.cpp for usage example -#pragma once +#ifndef SPDLOG_H +#define SPDLOG_H #include "common.h" #include "logger.h" @@ -202,3 +203,4 @@ void drop_all(); } // namespace spdlog #include "details/spdlog_impl.h" +#endif diff --git a/include/spdlog/tweakme.h b/include/spdlog/tweakme.h index 50ad3fb4..fc846b5e 100644 --- a/include/spdlog/tweakme.h +++ b/include/spdlog/tweakme.h @@ -3,7 +3,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#pragma once +#ifndef TWEAKME_H +#define TWEAKME_H /////////////////////////////////////////////////////////////////////////////// // @@ -141,3 +142,4 @@ // // #define SPDLOG_LEVEL_NAMES { "MY TRACE", "MY DEBUG", "MY INFO", "MY WARNING", "MY ERROR", "MY CRITICAL", "OFF" } /////////////////////////////////////////////////////////////////////////////// +#endif