Skip to content

Commit 16880c0

Browse files
authored
Merge pull request #29 from rsl-org/compat/gcc
gcc compat
2 parents 9635b13 + 6c469a7 commit 16880c0

File tree

33 files changed

+604
-446
lines changed

33 files changed

+604
-446
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RslUtilRecipe(ConanFile):
2525
exports_sources = "CMakeLists.txt", "include/*", "test/*", "cmake/*"
2626
def requirements(self):
2727
if self.options.tests:
28-
self.requires("gtest/1.14.0")
28+
self.requires("gtest/1.17.0")
2929

3030
def layout(self):
3131
cmake_layout(self)

include/rsl/_impl/format/fmt_parser.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ struct Replacement final : _impl::Parser {
100100

101101
using _impl::Parser::Parser;
102102

103-
constexpr void add_style(FormatString& out, bool enable) const {
103+
consteval void add_style(FormatString& out, bool enable) const {
104104
if (!style_tags.empty()) {
105105
out.string += style_separator;
106106
out.style_tags.emplace_back(style_tags, enable);
107107
}
108108
}
109109

110-
constexpr void render(FormatString& out) const {
110+
consteval void render(FormatString& out) const {
111111
if (kind == ReplacementType::invalid) {
112112
// todo emit error?
113113
return;
@@ -223,7 +223,7 @@ struct FormatParser : _impl::Parser {
223223

224224
FormatString result;
225225

226-
constexpr void push_text(int start, int end) { result.string += data.substr(start, end - start); }
226+
consteval void push_text(int start, int end) { result.string += data.substr(start, end - start); }
227227

228228
consteval static std::meta::info get_arg_accessor(std::size_t index) {
229229
return substitute(^^Accessor, {std::meta::reflect_constant(index)});

include/rsl/_impl/macro/compiler.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
#define RSL_VERSION_ENCODE(major, minor, patch) ((major) * 1000000 + (minor) * 1000 + (patch))
1010

1111
#if defined(__clang__)
12-
# define RSL_COMPILER RSL_COMPILER_CLANG
12+
# define RSL_COMPILER RSL_COMPILER_CLANG
13+
# define RSL_COMPILER_ID clang
1314
# define RSL_COMPILER_VERSION \
1415
RSL_VERSION_ENCODE(__clang_major__, __clang_minor__, __clang_patchlevel__)
1516
#elif defined(__GNUC__)
1617
# define RSL_COMPILER RSL_COMPILER_GCC
18+
# define RSL_COMPILER_ID GCC
1719
# define RSL_COMPILER_VERSION RSL_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
1820
#elif defined(_MSC_VER)
19-
# define RSL_COMPILER RSL_COMPILER_MSVC
21+
# define RSL_COMPILER RSL_COMPILER_MSVC
22+
# define RSL_COMPILER_ID MSVC
2023
# if defined(_MSC_FULL_VER)
2124
# define RSL_COMPILER_VERSION _MSC_FULL_VER
2225
# else
@@ -25,6 +28,7 @@
2528

2629
#else
2730
# define RSL_COMPILER RSL_COMPILER_UNKNOWN
31+
# define RSL_COMPILER_ID UNKNOWN
2832
# define RSL_COMPILER_VERSION 0
2933
#endif
3034

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
3+
#include "compiler.hpp"
4+
5+
#define RSL_STRINGIZE_IMPL(x) #x
6+
#define RSL_STRINGIZE(x) RSL_STRINGIZE_IMPL(x)
7+
#if RSL_COMPILER == RSL_COMPILER_MSVC
8+
# define RSL_PRAGMA(x) __pragma(x)
9+
#else
10+
# define RSL_PRAGMA(x) _Pragma(RSL_STRINGIZE(x))
11+
#endif
12+
13+
14+
#if RSL_COMPILER == RSL_COMPILER_MSVC
15+
# define RSL_DIAG_PUSH RSL_PRAGMA(warning(push))
16+
# define RSL_DIAG_POP RSL_PRAGMA(warning(pop))
17+
# define RSL_DIAG_DISABLE(id) RSL_PRAGMA(warning(disable : RSL_DIAGS_##id))
18+
# define RSL_DIAG_ERROR(id) RSL_PRAGMA(warning(error : RSL_DIAGS_##id))
19+
#elif RSL_COMPILER == RSL_COMPILER_GCC || RSL_COMPILER == RSL_COMPILER_CLANG
20+
# define RSL_DIAG_PUSH RSL_PRAGMA(RSL_COMPILER_ID diagnostic push)
21+
# define RSL_DIAG_POP RSL_PRAGMA(RSL_COMPILER_ID diagnostic pop)
22+
# define RSL_DIAG_DISABLE(w) RSL_PRAGMA(RSL_COMPILER_ID diagnostic ignored RSL_DIAGS_##w)
23+
# define RSL_DIAG_ERROR(w) RSL_PRAGMA(RSL_COMPILER_ID diagnostic error RSL_DIAGS_##w)
24+
#else
25+
# warning "Unsupported compiler"
26+
#endif
27+
28+
#define RSL_IMPL_CONSUME(...)
29+
#define RSL_DIAG_push RSL_DIAG_PUSH RSL_IMPL_CONSUME
30+
#define RSL_DIAG_pop RSL_DIAG_POP RSL_IMPL_CONSUME
31+
#define RSL_DIAG_disable RSL_DIAG_DISABLE
32+
#define RSL_DIAG_error RSL_DIAG_ERROR
33+
34+
// Diagnostic map
35+
#if RSL_COMPILER == RSL_COMPILER_MSVC
36+
# define RSL_DIAGS_literal_suffix 4455
37+
# define RSL_DIAGS_narrowing 4838
38+
#elif RSL_COMPILER == RSL_COMPILER_GCC
39+
# define RSL_DIAGS_literal_suffix "-Wliteral-suffix"
40+
# define RSL_DIAGS_narrowing "-Wnarrowing"
41+
#elif RSL_COMPILER == RSL_COMPILER_CLANG
42+
# define RSL_DIAGS_literal_suffix "-Wuser-defined-literals"
43+
# define RSL_DIAGS_narrowing "-Wc++11-narrowing"
44+
#else
45+
# warning "Unsupported compiler"
46+
#endif

include/rsl/_impl/macro/loop.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#define RSL_IMPL_PARENS ()
4+
5+
#define RSL_IMPL_EXPAND(...) RSL_IMPL_EXPAND4(RSL_IMPL_EXPAND4(RSL_IMPL_EXPAND4(RSL_IMPL_EXPAND4(__VA_ARGS__))))
6+
#define RSL_IMPL_EXPAND4(...) RSL_IMPL_EXPAND3(RSL_IMPL_EXPAND3(RSL_IMPL_EXPAND3(RSL_IMPL_EXPAND3(__VA_ARGS__))))
7+
#define RSL_IMPL_EXPAND3(...) RSL_IMPL_EXPAND2(RSL_IMPL_EXPAND2(RSL_IMPL_EXPAND2(RSL_IMPL_EXPAND2(__VA_ARGS__))))
8+
#define RSL_IMPL_EXPAND2(...) RSL_IMPL_EXPAND1(RSL_IMPL_EXPAND1(RSL_IMPL_EXPAND1(RSL_IMPL_EXPAND1(__VA_ARGS__))))
9+
#define RSL_IMPL_EXPAND1(...) __VA_ARGS__
10+
11+
#define RSL_IMPL_FOR_EACH_DELIM(macro, delim, ...) \
12+
__VA_OPT__(RSL_IMPL_EXPAND(RSL_IMPL_FOR_EACH_DELIM_HELPER(macro, delim, __VA_ARGS__)))
13+
#define RSL_IMPL_FOR_EACH_DELIM_HELPER(macro, delim, a1, ...) \
14+
macro(a1) \
15+
__VA_OPT__(delim() RSL_IMPL_FOR_EACH_DELIM_AGAIN RSL_IMPL_PARENS (macro, delim, __VA_ARGS__))
16+
#define RSL_IMPL_FOR_EACH_DELIM_AGAIN() RSL_IMPL_FOR_EACH_DELIM_HELPER
17+
18+
#define RSL_IMPL_DELIM_NONE()
19+
#define RSL_IMPL_DELIM_COMMA() ,

include/rsl/_impl/member_cache.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct MemberAccessor {
6060
static consteval bool has_member(std::string_view name) { return get_index_of(name) != -1UZ; }
6161
};
6262

63-
template <auto... Members>
63+
template <std::meta::info... Members>
6464
constexpr inline MemberAccessor<Members...> member_cache{};
6565

6666
consteval auto cache_members(auto&& member_range) {

include/rsl/annotations

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include <rsl/meta_traits>
2+
#include <rsl/meta>
33
#include <rsl/serialize> // for preferred_name annotation
44

55
#include <rsl/serializer/repr.hpp>

0 commit comments

Comments
 (0)