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 @@
#include <sstream>
namespace rlib {
namespace impl {
#if RLIB_CXX_STD < 2017
//#if RLIB_CXX_STD < 2017
bool enable_endl_flush = true;
int max_predefined_log_level = (int)log_level_t::DEBUG;
NullStreamBuf null_streambuf;
#endif
#ifndef RLIB_MINGW_DISABLE_TLS
#if RLIB_CXX_STD < 2017
//#endif
//#ifndef RLIB_MINGW_DISABLE_TLS
//#if RLIB_CXX_STD < 2017
thread_local std::stringstream _format_string_helper_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);
#endif
//#endif
}
......@@ -36,11 +36,11 @@ namespace rlib {
// Allow extension.
enum class log_level_t : int { FATAL = 1, ERROR, WARNING, INFO, VERBOSE, DEBUG };
namespace impl {
#if RLIB_CXX_STD < 2017
//#if RLIB_CXX_STD < 2017
extern int max_predefined_log_level;
#else
inline int max_predefined_log_level = (int)log_level_t::DEBUG;
#endif
//#else
// inline int max_predefined_log_level = (int)log_level_t::DEBUG;
//#endif
}
/*
How to update log_level_t:
......
......@@ -80,11 +80,11 @@ namespace rlib {
size_t printfln(const std::string &fmt, Args... args);
namespace impl {
#if RLIB_CXX_STD < 2017
//#if RLIB_CXX_STD < 2017
extern bool enable_endl_flush;
#else
inline bool enable_endl_flush = true;
#endif
//#else
// inline bool enable_endl_flush = true;
//#endif
}
inline bool sync_with_stdio(bool sync = true) noexcept {
......
......@@ -3,13 +3,6 @@
#include <iostream>
#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 impl {
class NullStreamBuf : public std::streambuf
......@@ -17,12 +10,13 @@ namespace rlib {
public:
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;
#else
RLIB_IMPL_VAR_DECL std::ostream null_stream(&impl::null_streambuf);
#endif
//#else
// inline std::ostream null_stream(&impl::null_streambuf);
//#endif
}
......@@ -28,14 +28,14 @@ namespace rlib {
// literals::_format, format_string, string::format
namespace impl {
#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.
thread_local extern std::stringstream to_string_by_sstream_ss;
thread_local extern std::stringstream _format_string_helper_ss;
#else
thread_local inline std::stringstream to_string_by_sstream_ss;
thread_local inline std::stringstream _format_string_helper_ss;
#endif
//#else
// thread_local inline std::stringstream to_string_by_sstream_ss;
// thread_local inline std::stringstream _format_string_helper_ss;
//#endif
#endif
template <typename VarT>
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