Skip to content
Snippets Groups Projects
Commit 344b3197 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

c++17: remove inline variable

parent 4ebdfc3b
No related branches found
No related tags found
No related merge requests found
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
#include <sstream> #include <sstream>
namespace rlib { namespace rlib {
namespace impl { namespace impl {
#if RLIB_CXX_STD < 2017 //#if RLIB_CXX_STD < 2017
bool enable_endl_flush = true; bool enable_endl_flush = true;
int max_predefined_log_level = (int)log_level_t::DEBUG; int max_predefined_log_level = (int)log_level_t::DEBUG;
NullStreamBuf null_streambuf; NullStreamBuf null_streambuf;
#endif //#endif
#ifndef RLIB_MINGW_DISABLE_TLS //#ifndef RLIB_MINGW_DISABLE_TLS
#if RLIB_CXX_STD < 2017 //#if RLIB_CXX_STD < 2017
thread_local std::stringstream _format_string_helper_ss; thread_local std::stringstream _format_string_helper_ss;
thread_local std::stringstream to_string_by_sstream_ss; thread_local std::stringstream to_string_by_sstream_ss;
#endif //#endif
#endif //#endif
} }
#if RLIB_CXX_STD < 2017 //#if RLIB_CXX_STD < 2017
std::ostream null_stream(&impl::null_streambuf); std::ostream null_stream(&impl::null_streambuf);
#endif //#endif
} }
...@@ -36,11 +36,11 @@ namespace rlib { ...@@ -36,11 +36,11 @@ namespace rlib {
// Allow extension. // Allow extension.
enum class log_level_t : int { FATAL = 1, ERROR, WARNING, INFO, VERBOSE, DEBUG }; enum class log_level_t : int { FATAL = 1, ERROR, WARNING, INFO, VERBOSE, DEBUG };
namespace impl { namespace impl {
#if RLIB_CXX_STD < 2017 //#if RLIB_CXX_STD < 2017
extern int max_predefined_log_level; extern int max_predefined_log_level;
#else //#else
inline int max_predefined_log_level = (int)log_level_t::DEBUG; // inline int max_predefined_log_level = (int)log_level_t::DEBUG;
#endif //#endif
} }
/* /*
How to update log_level_t: How to update log_level_t:
......
...@@ -80,11 +80,11 @@ namespace rlib { ...@@ -80,11 +80,11 @@ namespace rlib {
size_t printfln(const std::string &fmt, Args... args); size_t printfln(const std::string &fmt, Args... args);
namespace impl { namespace impl {
#if RLIB_CXX_STD < 2017 //#if RLIB_CXX_STD < 2017
extern bool enable_endl_flush; extern bool enable_endl_flush;
#else //#else
inline bool enable_endl_flush = true; // inline bool enable_endl_flush = true;
#endif //#endif
} }
inline bool sync_with_stdio(bool sync = true) noexcept { inline bool sync_with_stdio(bool sync = true) noexcept {
......
...@@ -3,13 +3,6 @@ ...@@ -3,13 +3,6 @@
#include <iostream> #include <iostream>
#include <rlib/sys/os.hpp> #include <rlib/sys/os.hpp>
// I'm testing this macro. if it works good, I'll apply it to rlib.
#if RLIB_CXX_STD >= 2017
#define RLIB_IMPL_VAR_DECL inline
#else
#define RLIB_IMPL_VAR_DECL extern
#endif
namespace rlib { namespace rlib {
namespace impl { namespace impl {
class NullStreamBuf : public std::streambuf class NullStreamBuf : public std::streambuf
...@@ -17,12 +10,13 @@ namespace rlib { ...@@ -17,12 +10,13 @@ namespace rlib {
public: public:
int overflow(int c) { return c; } int overflow(int c) { return c; }
}; };
RLIB_IMPL_VAR_DECL NullStreamBuf null_streambuf; // stdc++ 17 removed
extern NullStreamBuf null_streambuf;
} }
#if RLIB_CXX_STD < 2017 //#if RLIB_CXX_STD < 2017
extern std::ostream null_stream; extern std::ostream null_stream;
#else //#else
RLIB_IMPL_VAR_DECL std::ostream null_stream(&impl::null_streambuf); // inline std::ostream null_stream(&impl::null_streambuf);
#endif //#endif
} }
...@@ -28,14 +28,14 @@ namespace rlib { ...@@ -28,14 +28,14 @@ namespace rlib {
// literals::_format, format_string, string::format // literals::_format, format_string, string::format
namespace impl { namespace impl {
#ifndef RLIB_MINGW_DISABLE_TLS #ifndef RLIB_MINGW_DISABLE_TLS
#if RLIB_CXX_STD < 2017 //#if RLIB_CXX_STD < 2017
// Intel C++ compiler has a pending bug for `thread_local inline` variable. // Intel C++ compiler has a pending bug for `thread_local inline` variable.
thread_local extern std::stringstream to_string_by_sstream_ss; thread_local extern std::stringstream to_string_by_sstream_ss;
thread_local extern std::stringstream _format_string_helper_ss; thread_local extern std::stringstream _format_string_helper_ss;
#else //#else
thread_local inline std::stringstream to_string_by_sstream_ss; // thread_local inline std::stringstream to_string_by_sstream_ss;
thread_local inline std::stringstream _format_string_helper_ss; // thread_local inline std::stringstream _format_string_helper_ss;
#endif //#endif
#endif #endif
template <typename VarT> template <typename VarT>
std::string to_string_by_sstream(VarT &thing) { std::string to_string_by_sstream(VarT &thing) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment