Skip to content

Commit 06df57d

Browse files
authored
internal linkage for constexpr variables for module use (#2428)
1 parent b270499 commit 06df57d

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

include/glaze/beve/header.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,43 +59,43 @@ namespace glz
5959

6060
namespace glz::tag
6161
{
62-
constexpr uint8_t null = 0;
63-
constexpr uint8_t boolean = 0b00001'000;
64-
constexpr uint8_t number = 1;
65-
constexpr uint8_t string = 2;
66-
constexpr uint8_t object = 3;
67-
constexpr uint8_t typed_array = 4;
68-
constexpr uint8_t generic_array = 5;
69-
constexpr uint8_t extensions = 6;
62+
inline constexpr uint8_t null = 0;
63+
inline constexpr uint8_t boolean = 0b00001'000;
64+
inline constexpr uint8_t number = 1;
65+
inline constexpr uint8_t string = 2;
66+
inline constexpr uint8_t object = 3;
67+
inline constexpr uint8_t typed_array = 4;
68+
inline constexpr uint8_t generic_array = 5;
69+
inline constexpr uint8_t extensions = 6;
7070

7171
// Data delimiter for separating multiple BEVE values in a stream/buffer
7272
// Used like NDJSON's newline delimiter - when converted to JSON outputs '\n'
73-
constexpr uint8_t delimiter = 0b00000'110; // extensions type (6) with subtype 0
73+
inline constexpr uint8_t delimiter = 0b00000'110; // extensions type (6) with subtype 0
7474

75-
constexpr uint8_t bool_false = 0b000'01'000;
76-
constexpr uint8_t bool_true = 0b000'11'000;
75+
inline constexpr uint8_t bool_false = 0b000'01'000;
76+
inline constexpr uint8_t bool_true = 0b000'11'000;
7777

78-
constexpr uint8_t i8 = 0b000'01'001;
79-
constexpr uint8_t i16 = 0b001'01'001;
80-
constexpr uint8_t i32 = 0b010'01'001;
81-
constexpr uint8_t i64 = 0b011'01'001;
82-
constexpr uint8_t i128 = 0b100'01'001;
78+
inline constexpr uint8_t i8 = 0b000'01'001;
79+
inline constexpr uint8_t i16 = 0b001'01'001;
80+
inline constexpr uint8_t i32 = 0b010'01'001;
81+
inline constexpr uint8_t i64 = 0b011'01'001;
82+
inline constexpr uint8_t i128 = 0b100'01'001;
8383

84-
constexpr uint8_t u8 = 0b000'10'001;
85-
constexpr uint8_t u16 = 0b001'10'001;
86-
constexpr uint8_t u32 = 0b010'10'001;
87-
constexpr uint8_t u64 = 0b011'10'001;
88-
constexpr uint8_t u128 = 0b100'10'001;
84+
inline constexpr uint8_t u8 = 0b000'10'001;
85+
inline constexpr uint8_t u16 = 0b001'10'001;
86+
inline constexpr uint8_t u32 = 0b010'10'001;
87+
inline constexpr uint8_t u64 = 0b011'10'001;
88+
inline constexpr uint8_t u128 = 0b100'10'001;
8989

90-
constexpr uint8_t bf16 = 0b000'00'001; // brain float
91-
constexpr uint8_t f16 = 0b001'00'001;
92-
constexpr uint8_t f32 = 0b010'00'001;
93-
constexpr uint8_t f64 = 0b011'00'001;
94-
constexpr uint8_t f128 = 0b100'00'001;
90+
inline constexpr uint8_t bf16 = 0b000'00'001; // brain float
91+
inline constexpr uint8_t f16 = 0b001'00'001;
92+
inline constexpr uint8_t f32 = 0b010'00'001;
93+
inline constexpr uint8_t f64 = 0b011'00'001;
94+
inline constexpr uint8_t f128 = 0b100'00'001;
9595

9696
// Aligned typed array: category 3, sub-type 2 (bit 6 set, bits 5 and 7 clear)
9797
// Layout: ALIGNED_HEADER | NUMERIC_HEADER | SIZE | PADDING_LENGTH | PADDING | DATA
98-
constexpr uint8_t aligned_typed_array = 0b010'11'100; // 0x5C
98+
inline constexpr uint8_t aligned_typed_array = 0b010'11'100; // 0x5C
9999
}
100100

101101
namespace glz

include/glaze/reflection/to_tuple.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ namespace glz
104104
}
105105
}();
106106

107-
constexpr size_t max_pure_reflection_count = 128;
107+
inline constexpr size_t max_pure_reflection_count = 128;
108108
#endif
109109
}
110110

include/glaze/util/fast_float.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ namespace glz::fast_float {
185185
enum class chars_format : uint64_t;
186186

187187
namespace detail {
188-
constexpr chars_format basic_json_fmt = chars_format(1 << 5);
189-
constexpr chars_format basic_fortran_fmt = chars_format(1 << 6);
188+
inline constexpr chars_format basic_json_fmt = chars_format(1 << 5);
189+
inline constexpr chars_format basic_fortran_fmt = chars_format(1 << 6);
190190
} // namespace detail
191191

192192
enum class chars_format : uint64_t {
@@ -577,10 +577,10 @@ struct adjusted_mantissa {
577577
};
578578

579579
// Bias so we can get the real exponent with an invalid adjusted_mantissa.
580-
constexpr static int32_t invalid_am_bias = -0x8000;
580+
inline constexpr int32_t invalid_am_bias = -0x8000;
581581

582582
// used for binary_format_lookup_tables<T>::max_mantissa
583-
constexpr uint64_t constant_55555 = 5 * 5 * 5 * 5 * 5;
583+
inline constexpr uint64_t constant_55555 = 5 * 5 * 5 * 5 * 5;
584584

585585
template <typename T, typename U = void> struct binary_format_lookup_tables;
586586

@@ -1167,7 +1167,7 @@ template <typename UC> constexpr bool is_space(UC c) {
11671167
return c < 256 && space_lut<>::value[uint8_t(c)];
11681168
}
11691169

1170-
template <typename UC> static constexpr uint64_t int_cmp_zeros() {
1170+
template <typename UC> constexpr uint64_t int_cmp_zeros() {
11711171
static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),
11721172
"Unsupported character size");
11731173
return (sizeof(UC) == 1) ? 0x3030303030303030
@@ -1177,7 +1177,7 @@ template <typename UC> static constexpr uint64_t int_cmp_zeros() {
11771177
: (uint64_t(UC('0')) << 32 | UC('0'));
11781178
}
11791179

1180-
template <typename UC> static constexpr int int_cmp_len() {
1180+
template <typename UC> constexpr int int_cmp_len() {
11811181
return sizeof(uint64_t) / sizeof(UC);
11821182
}
11831183

@@ -2980,11 +2980,11 @@ namespace glz::fast_float {
29802980
#if defined(GLZ_FASTFLOAT_64BIT) && !defined(__sparc)
29812981
#define GLZ_FASTFLOAT_64BIT_LIMB 1
29822982
typedef uint64_t limb;
2983-
constexpr size_t limb_bits = 64;
2983+
inline constexpr size_t limb_bits = 64;
29842984
#else
29852985
#define GLZ_FASTFLOAT_32BIT_LIMB
29862986
typedef uint32_t limb;
2987-
constexpr size_t limb_bits = 32;
2987+
inline constexpr size_t limb_bits = 32;
29882988
#endif
29892989

29902990
typedef span<limb> limb_span;
@@ -2993,8 +2993,8 @@ typedef span<limb> limb_span;
29932993
// of bits required to store the largest bigint, which is
29942994
// `log2(10**(digits + max_exp))`, or `log2(10**(767 + 342))`, or
29952995
// ~3600 bits, so we round to 4000.
2996-
constexpr size_t bigint_bits = 4000;
2997-
constexpr size_t bigint_limbs = bigint_bits / limb_bits;
2996+
inline constexpr size_t bigint_bits = 4000;
2997+
inline constexpr size_t bigint_limbs = bigint_bits / limb_bits;
29982998

29992999
// vector-like type that is allocated on the stack. the entire
30003000
// buffer is pre-allocated, and only the length changes.
@@ -3610,7 +3610,7 @@ struct bigint : pow5_tables<> {
36103610
namespace glz::fast_float {
36113611

36123612
// 1e0 to 1e19
3613-
constexpr static uint64_t powers_of_ten_uint64[] = {1UL,
3613+
inline constexpr uint64_t powers_of_ten_uint64[] = {1UL,
36143614
10UL,
36153615
100UL,
36163616
1000UL,

include/glaze/util/parse.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,16 @@ namespace glz
269269

270270
namespace unicode
271271
{
272-
constexpr uint32_t generic_surrogate_mask = 0xF800;
273-
constexpr uint32_t generic_surrogate_value = 0xD800;
272+
inline constexpr uint32_t generic_surrogate_mask = 0xF800;
273+
inline constexpr uint32_t generic_surrogate_value = 0xD800;
274274

275-
constexpr uint32_t surrogate_mask = 0xFC00;
276-
constexpr uint32_t high_surrogate_value = 0xD800;
277-
constexpr uint32_t low_surrogate_value = 0xDC00;
275+
inline constexpr uint32_t surrogate_mask = 0xFC00;
276+
inline constexpr uint32_t high_surrogate_value = 0xD800;
277+
inline constexpr uint32_t low_surrogate_value = 0xDC00;
278278

279-
constexpr uint32_t surrogate_codepoint_offset = 0x10000;
280-
constexpr uint32_t surrogate_codepoint_mask = 0x03FF;
281-
constexpr uint32_t surrogate_codepoint_bits = 10;
279+
inline constexpr uint32_t surrogate_codepoint_offset = 0x10000;
280+
inline constexpr uint32_t surrogate_codepoint_mask = 0x03FF;
281+
inline constexpr uint32_t surrogate_codepoint_bits = 10;
282282
}
283283

284284
template <class SrcChar, class DstChar = SrcChar>

include/glaze/util/simple_float.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ namespace glz::simple_float
3333
int32_t exp10{};
3434
};
3535

36-
static constexpr int32_t max_exp10 = 400;
37-
static constexpr int32_t min_exp10 = -400;
36+
inline constexpr int32_t max_exp10 = 400;
37+
inline constexpr int32_t min_exp10 = -400;
3838

3939
// Strict JSON-compliant number parser
4040
// JSON number format (RFC 8259):

0 commit comments

Comments
 (0)