Repository :
https://github.com/FarGroup/FarManager
On branch : master
Link :
https://github.com/FarGroup/FarManager/commit/adac3d0e02030560ebba94e2e9406f9f44faf495
>---------------------------------------------------------------
commit adac3d0e02030560ebba94e2e9406f9f44faf495
Author: Alex Alabuzhev <
alab...@gmail.com>
Date: Sat Oct 4 00:01:37 2025 +0100
Reorganize headers
>---------------------------------------------------------------
adac3d0e02030560ebba94e2e9406f9f44faf495
far/common.tests.cpp | 2 +-
far/common/cpp.hpp | 187 -------------------------------------------
far/common/polyfills.hpp | 148 ++++++++++++++++++++++++++++++++++
far/common/shims_post.hpp | 102 +++++++++++++++++++++++
far/common/shims_pre.hpp | 80 ++++++++++++++++++
far/common/string_utils.hpp | 2 +-
far/common/utility.hpp | 2 +-
far/far.vcxproj | 4 +-
far/far.vcxproj.filters | 12 ++-
far/headers.hpp | 25 +-----
plugins/tmppanel/headers.hpp | 11 ---
11 files changed, 349 insertions(+), 226 deletions(-)
diff --git a/far/common.tests.cpp b/far/common.tests.cpp
index ba92947ef..c80989060 100644
--- a/far/common.tests.cpp
+++ b/far/common.tests.cpp
@@ -86,7 +86,7 @@ TEST_CASE("common.NullToEmpty")
//----------------------------------------------------------------------------
#if COMPILER(GCC)
-#include "common/cpp.hpp"
+#include "common/polyfills.hpp"
TEST_CASE("cpp.const_return")
{
diff --git a/far/common/cpp.hpp b/far/common/cpp.hpp
deleted file mode 100644
index 00265ceab..000000000
--- a/far/common/cpp.hpp
+++ /dev/null
@@ -1,187 +0,0 @@
-#ifndef CPP_HPP_95E41B70_5DB2_4E5B_A468_95343C6438AD
-#define CPP_HPP_95E41B70_5DB2_4E5B_A468_95343C6438AD
-#pragma once
-
-/*
-cpp.hpp
-
-Some workarounds & emulations for C++ features, missed in currently used compilers & libraries.
-
-Here be dragons
-*/
-/*
-Copyright © 2013 Far Group
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. The name of the authors may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "compiler.hpp"
-
-#include <version>
-
-//----------------------------------------------------------------------------
-
-#ifdef FAR_ENABLE_CORRECT_ISO_CPP_WCHAR_H_OVERLOADS
-// These inline implementations in gcc/cwchar are wrong and non-compilable if _CONST_RETURN is defined.
-namespace std
-{
- inline wchar_t* wcschr(wchar_t* p, wchar_t c)
- {
- return const_cast<wchar_t*>(wcschr(const_cast<const wchar_t*>(p), c));
- }
-
- inline wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2)
- {
- return const_cast<wchar_t*>(wcspbrk(const_cast<const wchar_t*>(s1), s2));
- }
-
- inline wchar_t* wcsrchr(wchar_t* p, wchar_t c)
- {
- return const_cast<wchar_t*>(wcsrchr(const_cast<const wchar_t*>(p), c));
- }
-
- inline wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2)
- {
- return const_cast<wchar_t*>(wcsstr(const_cast<const wchar_t*>(s1), s2));
- }
-
- inline wchar_t* wmemchr(wchar_t* p, wchar_t c, size_t n)
- {
- return const_cast<wchar_t*>(wmemchr(const_cast<const wchar_t*>(p), c, n));
- }
-}
-
-using std::wcschr;
-using std::wcspbrk;
-using std::wcsrchr;
-using std::wcsstr;
-using std::wmemchr;
-
-#endif
-
-//----------------------------------------------------------------------------
-
-#if COMPILER(GCC) && !defined(_GLIBCXX_HAS_GTHREADS)
-
-namespace std::this_thread
-{
- inline void yield() noexcept
- {
- Sleep(0);
- }
-}
-#endif
-
-//----------------------------------------------------------------------------
-
-#ifndef __cpp_lib_to_underlying
-#include <type_traits>
-
-namespace std
-{
- template<class enum_type>
- [[nodiscard]]
- constexpr auto to_underlying(enum_type const Enum) noexcept
- {
- return static_cast<std::underlying_type_t<enum_type>>(Enum);
- }
-}
-#endif
-
-#ifndef __cpp_lib_unreachable
-#include <cassert>
-
-namespace std
-{
- [[noreturn]]
- inline void unreachable()
- {
- assert(false);
-
-#if COMPILER(CL)
- __assume(0);
-#else
- __builtin_unreachable();
-#endif
- }
-}
-#endif
-
-#ifndef __cpp_lib_ranges_fold
-#include <algorithm>
-#if !defined _LIBCPP___ALGORITHM_FOLD_H && !defined _LIBCPP___ALGORITHM_RANGES_FOLD_H // as of March 2025 libc++ doesn't define __cpp_lib_ranges_fold
-#include <functional>
-#include <iterator>
-#include <ranges>
-#include <type_traits>
-#include <utility>
-
-namespace std::ranges
-{
- struct fold_left_fn
- {
- template<std::input_iterator I, std::sentinel_for<I> S, typename T, typename F>
- constexpr auto operator()(I first, S last, T init, F f) const
- {
- using U = std::decay_t<std::invoke_result_t<F&, T, std::iter_reference_t<I>>>;
- if (first == last)
- return U(std::move(init));
- U accum = std::invoke(f, std::move(init), *first);
- for (++first; first != last; ++first)
- accum = std::invoke(f, std::move(accum), *first);
- return std::move(accum);
- }
-
- template<ranges::input_range R, typename T, typename F>
- constexpr auto operator()(R&& r, T init, F f) const
- {
- return (*this)(ranges::begin(r), ranges::end(r), std::move(init), std::ref(f));
- }
- };
-
- inline constexpr fold_left_fn fold_left;
-}
-#endif
-#endif
-
-#ifndef __cpp_size_t_suffix
-
-WARNING_PUSH()
-WARNING_DISABLE_MSC(4455) // 'operator operator': literal suffix identifiers that do not start with an underscore are reserved
-
-[[nodiscard]] consteval size_t operator""uz(unsigned long long const Value) noexcept { return Value; }
-[[nodiscard]] consteval size_t operator""Uz(unsigned long long const Value) noexcept { return Value; }
-[[nodiscard]] consteval size_t operator""uZ(unsigned long long const Value) noexcept { return Value; }
-[[nodiscard]] consteval size_t operator""UZ(unsigned long long const Value) noexcept { return Value; }
-[[nodiscard]] consteval size_t operator""zu(unsigned long long const Value) noexcept { return Value; }
-[[nodiscard]] consteval size_t operator""Zu(unsigned long long const Value) noexcept { return Value; }
-[[nodiscard]] consteval size_t operator""zU(unsigned long long const Value) noexcept { return Value; }
-[[nodiscard]] consteval size_t operator""ZU(unsigned long long const Value) noexcept { return Value; }
-
-WARNING_POP()
-
-#endif
-//----------------------------------------------------------------------------
-
-#endif // CPP_HPP_95E41B70_5DB2_4E5B_A468_95343C6438AD
diff --git a/far/common/polyfills.hpp b/far/common/polyfills.hpp
new file mode 100644
index 000000000..66354b091
--- /dev/null
+++ b/far/common/polyfills.hpp
@@ -0,0 +1,148 @@
+#ifndef POLYFILLS_HPP_95E41B70_5DB2_4E5B_A468_95343C6438AD
+#define POLYFILLS_HPP_95E41B70_5DB2_4E5B_A468_95343C6438AD
+#pragma once
+
+/*
+polyfills.hpp
+
+Emulation of C++ features missing in supported compilers & libraries
+
+Here be dragons
+*/
+/*
+Copyright © 2013 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "compiler.hpp"
+
+#include <version>
+
+//----------------------------------------------------------------------------
+
+#if COMPILER(GCC) && !defined(_GLIBCXX_HAS_GTHREADS)
+
+namespace std::this_thread
+{
+ inline void yield() noexcept
+ {
+ Sleep(0);
+ }
+}
+#endif
+
+//----------------------------------------------------------------------------
+
+#ifndef __cpp_lib_to_underlying
+#include <type_traits>
+
+namespace std
+{
+ template<class enum_type>
+ [[nodiscard]]
+ constexpr auto to_underlying(enum_type const Enum) noexcept
+ {
+ return static_cast<std::underlying_type_t<enum_type>>(Enum);
+ }
+}
+#endif
+
+#ifndef __cpp_lib_unreachable
+#include <cassert>
+
+namespace std
+{
+ [[noreturn]]
+ inline void unreachable()
+ {
+ assert(false);
+
+#if COMPILER(CL)
+ __assume(0);
+#else
+ __builtin_unreachable();
+#endif
+ }
+}
+#endif
+
+#ifndef __cpp_lib_ranges_fold
+#include <algorithm>
+#if !defined _LIBCPP___ALGORITHM_FOLD_H && !defined _LIBCPP___ALGORITHM_RANGES_FOLD_H // as of March 2025 libc++ doesn't define __cpp_lib_ranges_fold
+#include <functional>
+#include <iterator>
+#include <ranges>
+#include <type_traits>
+#include <utility>
+
+namespace std::ranges
+{
+ struct fold_left_fn
+ {
+ template<std::input_iterator I, std::sentinel_for<I> S, typename T, typename F>
+ constexpr auto operator()(I first, S last, T init, F f) const
+ {
+ using U = std::decay_t<std::invoke_result_t<F&, T, std::iter_reference_t<I>>>;
+ if (first == last)
+ return U(std::move(init));
+ U accum = std::invoke(f, std::move(init), *first);
+ for (++first; first != last; ++first)
+ accum = std::invoke(f, std::move(accum), *first);
+ return std::move(accum);
+ }
+
+ template<ranges::input_range R, typename T, typename F>
+ constexpr auto operator()(R&& r, T init, F f) const
+ {
+ return (*this)(ranges::begin(r), ranges::end(r), std::move(init), std::ref(f));
+ }
+ };
+
+ inline constexpr fold_left_fn fold_left;
+}
+#endif
+#endif
+
+#ifndef __cpp_size_t_suffix
+
+WARNING_PUSH()
+WARNING_DISABLE_MSC(4455) // 'operator operator': literal suffix identifiers that do not start with an underscore are reserved
+
+[[nodiscard]] consteval size_t operator""uz(unsigned long long const Value) noexcept { return Value; }
+[[nodiscard]] consteval size_t operator""Uz(unsigned long long const Value) noexcept { return Value; }
+[[nodiscard]] consteval size_t operator""uZ(unsigned long long const Value) noexcept { return Value; }
+[[nodiscard]] consteval size_t operator""UZ(unsigned long long const Value) noexcept { return Value; }
+[[nodiscard]] consteval size_t operator""zu(unsigned long long const Value) noexcept { return Value; }
+[[nodiscard]] consteval size_t operator""Zu(unsigned long long const Value) noexcept { return Value; }
+[[nodiscard]] consteval size_t operator""zU(unsigned long long const Value) noexcept { return Value; }
+[[nodiscard]] consteval size_t operator""ZU(unsigned long long const Value) noexcept { return Value; }
+
+WARNING_POP()
+
+#endif
+
+//----------------------------------------------------------------------------
+
+#endif // POLYFILLS_HPP_95E41B70_5DB2_4E5B_A468_95343C6438AD
diff --git a/far/common/shims_post.hpp b/far/common/shims_post.hpp
new file mode 100644
index 000000000..1a2639896
--- /dev/null
+++ b/far/common/shims_post.hpp
@@ -0,0 +1,102 @@
+#ifndef SHIMS_POST_HPP_8044E77C_AF33_4C40_8C9A_59C722E54280
+#define SHIMS_POST_HPP_8044E77C_AF33_4C40_8C9A_59C722E54280
+#pragma once
+
+/*
+shims_post.hpp
+
+Workarounds for supported compilers & libraries
+
+Here be dragons
+*/
+/*
+Copyright © 2025 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "compiler.hpp"
+
+#include <version>
+
+//----------------------------------------------------------------------------
+
+#if COMPILER(CL)
+
+
+
+#endif
+
+//----------------------------------------------------------------------------
+
+#if COMPILER(GCC)
+
+// These inline implementations in gcc/cwchar are wrong and non-compilable if _CONST_RETURN is defined.
+namespace std
+{
+ inline wchar_t* wcschr(wchar_t* p, wchar_t c)
+ {
+ return const_cast<wchar_t*>(wcschr(const_cast<const wchar_t*>(p), c));
+ }
+
+ inline wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2)
+ {
+ return const_cast<wchar_t*>(wcspbrk(const_cast<const wchar_t*>(s1), s2));
+ }
+
+ inline wchar_t* wcsrchr(wchar_t* p, wchar_t c)
+ {
+ return const_cast<wchar_t*>(wcsrchr(const_cast<const wchar_t*>(p), c));
+ }
+
+ inline wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2)
+ {
+ return const_cast<wchar_t*>(wcsstr(const_cast<const wchar_t*>(s1), s2));
+ }
+
+ inline wchar_t* wmemchr(wchar_t* p, wchar_t c, size_t n)
+ {
+ return const_cast<wchar_t*>(wmemchr(const_cast<const wchar_t*>(p), c, n));
+ }
+}
+
+using std::wcschr;
+using std::wcspbrk;
+using std::wcsrchr;
+using std::wcsstr;
+using std::wmemchr;
+
+#endif
+
+//----------------------------------------------------------------------------
+
+#if COMPILER(CLANG)
+
+
+
+#endif
+
+//----------------------------------------------------------------------------
+
+#endif // SHIMS_POST_HPP_8044E77C_AF33_4C40_8C9A_59C722E54280
diff --git a/far/common/shims_pre.hpp b/far/common/shims_pre.hpp
new file mode 100644
index 000000000..58cedf289
--- /dev/null
+++ b/far/common/shims_pre.hpp
@@ -0,0 +1,80 @@
+#ifndef SHIMS_PRE_HPP_A18E0B5A_ECE5_4B78_96AA_55FE47AB1DEC
+#define SHIMS_PRE_HPP_A18E0B5A_ECE5_4B78_96AA_55FE47AB1DEC
+#pragma once
+
+/*
+shims_pre.hpp
+
+Workarounds for supported compilers & libraries
+
+Here be dragons
+*/
+/*
+Copyright © 2025 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "compiler.hpp"
+
+#include <version>
+
+//----------------------------------------------------------------------------
+
+#if COMPILER(CL)
+
+
+
+#endif
+
+//----------------------------------------------------------------------------
+
+#if COMPILER(GCC)
+
+// Current implementation of wcschr etc. in gcc removes const from the returned pointer. The issue has been opened since 2007.
+// These semi-magical defines and appropriate inline overloads in shims_post.hpp are intended to fix this madness.
+
+// Force C version to return const
+#undef _CONST_RETURN
+#define _CONST_RETURN const
+// Disable broken inline overloads
+#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
+
+#endif
+
+//----------------------------------------------------------------------------
+
+#if COMPILER(CLANG)
+
+WARNING_PUSH()
+WARNING_DISABLE_CLANG("-Wbuiltin-macro-redefined")
+// Seems to be broken in v20 or incompatible with libstdc++ headers
+#undef __cpp_explicit_this_parameter
+WARNING_POP()
+
+#endif
+
+//----------------------------------------------------------------------------
+
+#endif // SHIMS_PRE_HPP_A18E0B5A_ECE5_4B78_96AA_55FE47AB1DEC
diff --git a/far/common/string_utils.hpp b/far/common/string_utils.hpp
index bb01aaf1d..9ebbabda9 100644
--- a/far/common/string_utils.hpp
+++ b/far/common/string_utils.hpp
@@ -32,7 +32,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "cpp.hpp"
+#include "polyfills.hpp"
#include "preprocessor.hpp"
#include "type_traits.hpp"
#include "utility.hpp"
diff --git a/far/common/utility.hpp b/far/common/utility.hpp
index da7bf453f..b335ef0b9 100644
--- a/far/common/utility.hpp
+++ b/far/common/utility.hpp
@@ -45,7 +45,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstddef>
#include <cstring>
-#include "cpp.hpp"
+#include "polyfills.hpp"
//----------------------------------------------------------------------------
diff --git a/far/far.vcxproj b/far/far.vcxproj
index 2dab1b42e..669f7fbfe 100644
--- a/far/far.vcxproj
+++ b/far/far.vcxproj
@@ -261,7 +261,6 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c
<ClInclude Include="common\bytes_view.hpp" />
<ClInclude Include="common\chrono.hpp" />
<ClInclude Include="common\compiler.hpp" />
- <ClInclude Include="common\cpp.hpp" />
<ClInclude Include="common\enum_substrings.hpp" />
<ClInclude Include="common\enum_tokens.hpp" />
<ClInclude Include="common\enumerator.hpp" />
@@ -281,9 +280,12 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c
<ClInclude Include="common\noncopyable.hpp" />
<ClInclude Include="common\null_iterator.hpp" />
<ClInclude Include="common\placement.hpp" />
+ <ClInclude Include="common\polyfills.hpp" />
<ClInclude Include="common\preprocessor.hpp" />
<ClInclude Include="common\scope_exit.hpp" />
<ClInclude Include="common\segment.hpp" />
+ <ClInclude Include="common\shims_pre.hpp" />
+ <ClInclude Include="common\shims_post.hpp" />
<ClInclude Include="common\singleton.hpp" />
<ClInclude Include="common\smart_ptr.hpp" />
<ClInclude Include="common\source_location.hpp" />
diff --git a/far/far.vcxproj.filters b/far/far.vcxproj.filters
index f056d1f7b..4bbd3b140 100644
--- a/far/far.vcxproj.filters
+++ b/far/far.vcxproj.filters
@@ -586,9 +586,6 @@
<ClInclude Include="common\compiler.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
- <ClInclude Include="common\cpp.hpp">
- <Filter>Header Files\common</Filter>
- </ClInclude>
<ClInclude Include="common\enum_substrings.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
@@ -646,6 +643,9 @@
<ClInclude Include="common\placement.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
+ <ClInclude Include="common\polyfills.hpp">
+ <Filter>Header Files\common</Filter>
+ </ClInclude>
<ClInclude Include="common\preprocessor.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
@@ -655,6 +655,12 @@
<ClInclude Include="common\segment.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
+ <ClInclude Include="common\shims_pre.hpp">
+ <Filter>Header Files\common</Filter>
+ </ClInclude>
+ <ClInclude Include="common\shims_post.hpp">
+ <Filter>Header Files\common</Filter>
+ </ClInclude>
<ClInclude Include="common\singleton.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
diff --git a/far/headers.hpp b/far/headers.hpp
index 3a1507121..88deb5d1f 100644
--- a/far/headers.hpp
+++ b/far/headers.hpp
@@ -45,26 +45,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#error Clang 16.0.0 (or higher) required
#endif
-#ifdef __GNUC__
-// Current implementation of wcschr etc. in gcc removes const from returned pointer. Issue has been opened since 2007.
-// These semi-magical defines and appropriate overloads in cpp.hpp are intended to fix this madness.
-
-// Force C version to return const
-#undef _CONST_RETURN
-#define _CONST_RETURN const
-// Disable broken inline overloads
-#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
-// Enable inline overloads in common/cpp.hpp
-#define FAR_ENABLE_CORRECT_ISO_CPP_WCHAR_H_OVERLOADS
-#endif
-
-#if COMPILER(CLANG)
-WARNING_PUSH()
-WARNING_DISABLE_CLANG("-Wbuiltin-macro-redefined")
-// Seems to be broken in v20 or incompatible with libstdc++ headers
-#undef __cpp_explicit_this_parameter
-WARNING_POP()
-#endif
+#include "common/shims_pre.hpp"
#include "disable_warnings_in_std_begin.hpp"
//----------------------------------------------------------------------------
@@ -127,7 +108,9 @@ WARNING_POP()
//----------------------------------------------------------------------------
#include "disable_warnings_in_std_end.hpp"
-#include "common/cpp.hpp"
+#include "common/shims_post.hpp"
+
+#include "common/polyfills.hpp"
using string = std::wstring;
using string_view = std::wstring_view;
diff --git a/plugins/tmppanel/headers.hpp b/plugins/tmppanel/headers.hpp
index bde9ecc61..f999b92d1 100644
--- a/plugins/tmppanel/headers.hpp
+++ b/plugins/tmppanel/headers.hpp
@@ -2,17 +2,6 @@
#define HEADERS_HPP_74234F4A_8C20_4AE2_A532_E93F003489D5
#pragma once
-#ifdef __GNUC__
-// Current implementation of wcschr etc. in gcc removes const from returned pointer. Issue has been opened since 2007.
-// These semi-magical defines and appropriate overloads in cpp.hpp are intended to fix this madness.
-
-// Force C version to return const
-#undef _CONST_RETURN
-#define _CONST_RETURN const
-// Disable broken inline overloads
-#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
-#endif
-
#include <algorithm>
#include <iterator>
#include <list>