Skip to content

Commit f6eba26

Browse files
authored
Merge pull request #196 from vadz/avoid-gcc-wundef
Avoid -Wundef warnings from gcc
2 parents 91a69a1 + 3ca9657 commit f6eba26

File tree

6 files changed

+62
-30
lines changed

6 files changed

+62
-30
lines changed

include/ctll/fixed_string.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ template <size_t N> struct fixed_string {
4242
bool correct_flag{true};
4343
template <typename T> constexpr fixed_string(const T (&input)[N+1]) noexcept {
4444
if constexpr (std::is_same_v<T, char>) {
45-
#if CTRE_STRING_IS_UTF8
45+
#ifdef CTRE_STRING_IS_UTF8
4646
size_t out{0};
4747
for (size_t i{0}; i < N; ++i) {
4848
if ((i == (N-1)) && (input[i] == 0)) break;
@@ -209,10 +209,4 @@ template <size_t N> fixed_string(fixed_string<N>) -> fixed_string<N>;
209209

210210
}
211211

212-
#if CTLL_CNTTP_COMPILER_CHECK
213-
#define CTLL_FIXED_STRING ctll::fixed_string
214-
#else
215-
#define CTLL_FIXED_STRING const auto &
216-
#endif
217-
218212
#endif

include/ctll/utilities.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@
33

44
#include <type_traits>
55

6-
#define CTLL_CNTTP_COMPILER_CHECK (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L) || ((__cpp_nontype_template_args >= 201411L) && (__clang_major__ >= 12) && !__apple_build_version__))
6+
#if defined __cpp_nontype_template_parameter_class
7+
#define CTLL_CNTTP_COMPILER_CHECK 1
8+
#elif defined __cpp_nontype_template_args
9+
#if __cpp_nontype_template_args >= 201911L
10+
#define CTLL_CNTTP_COMPILER_CHECK 1
11+
#elif __cpp_nontype_template_args >= 201411L
12+
#if defined __clang_major__ && __clang_major__ >= 12
13+
#if !defined __apple_build_version__ || !__apple_build_version__
14+
#define CTLL_CNTTP_COMPILER_CHECK 1
15+
#endif
16+
#endif
17+
#endif
18+
#endif
19+
20+
#ifndef CTLL_CNTTP_COMPILER_CHECK
21+
#define CTLL_CNTTP_COMPILER_CHECK 0
22+
#endif
723

824
#ifdef _MSC_VER
925
#define CTLL_FORCE_INLINE __forceinline

include/ctre/range.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ template <typename... Ts> constexpr bool is_range<multi_subject_range<Ts...>> =
133133

134134
}
135135

136-
#if __cpp_lib_ranges >= 201911
136+
#if defined __cpp_lib_ranges && __cpp_lib_ranges >= 201911
137137
namespace std::ranges {
138138

139139
template <typename... Ts> inline constexpr bool enable_borrowed_range<::ctre::regex_range<Ts...>> = true;

include/ctre/utility.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#ifndef CTRE__UTILITY__HPP
22
#define CTRE__UTILITY__HPP
33

4-
#define CTRE_CNTTP_COMPILER_CHECK (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L) || ((__cpp_nontype_template_args >= 201411L) && (__clang_major__ >= 12) && !__apple_build_version__))
4+
#include "../ctll/utilities.hpp"
5+
6+
#define CTRE_CNTTP_COMPILER_CHECK CTLL_CNTTP_COMPILER_CHECK
57

68
#if __GNUC__ > 9
79
#if __has_cpp_attribute(likely)

single-header/ctre-unicode.hpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ template <size_t N> struct fixed_string {
277277
bool correct_flag{true};
278278
template <typename T> constexpr fixed_string(const T (&input)[N+1]) noexcept {
279279
if constexpr (std::is_same_v<T, char>) {
280-
#if CTRE_STRING_IS_UTF8
280+
#ifdef CTRE_STRING_IS_UTF8
281281
size_t out{0};
282282
for (size_t i{0}; i < N; ++i) {
283283
if ((i == (N-1)) && (input[i] == 0)) break;
@@ -444,12 +444,6 @@ template <size_t N> fixed_string(fixed_string<N>) -> fixed_string<N>;
444444

445445
}
446446

447-
#if CTLL_CNTTP_COMPILER_CHECK
448-
#define CTLL_FIXED_STRING ctll::fixed_string
449-
#else
450-
#define CTLL_FIXED_STRING const auto &
451-
#endif
452-
453447
#endif
454448

455449
#ifndef CTLL__TYPE_STACK__HPP
@@ -460,7 +454,23 @@ template <size_t N> fixed_string(fixed_string<N>) -> fixed_string<N>;
460454

461455
#include <type_traits>
462456

463-
#define CTLL_CNTTP_COMPILER_CHECK (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L) || ((__cpp_nontype_template_args >= 201411L) && (__clang_major__ >= 12) && !__apple_build_version__))
457+
#if defined __cpp_nontype_template_parameter_class
458+
#define CTLL_CNTTP_COMPILER_CHECK 1
459+
#elif defined __cpp_nontype_template_args
460+
#if __cpp_nontype_template_args >= 201911L
461+
#define CTLL_CNTTP_COMPILER_CHECK 1
462+
#elif __cpp_nontype_template_args >= 201411L
463+
#if defined __clang_major__ && __clang_major__ >= 12
464+
#if !defined __apple_build_version__ || !__apple_build_version__
465+
#define CTLL_CNTTP_COMPILER_CHECK 1
466+
#endif
467+
#endif
468+
#endif
469+
#endif
470+
471+
#ifndef CTLL_CNTTP_COMPILER_CHECK
472+
#define CTLL_CNTTP_COMPILER_CHECK 0
473+
#endif
464474

465475
#ifdef _MSC_VER
466476
#define CTLL_FORCE_INLINE __forceinline
@@ -1340,7 +1350,7 @@ struct pcre {
13401350
#ifndef CTRE__UTILITY__HPP
13411351
#define CTRE__UTILITY__HPP
13421352

1343-
#define CTRE_CNTTP_COMPILER_CHECK (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L) || ((__cpp_nontype_template_args >= 201411L) && (__clang_major__ >= 12) && !__apple_build_version__))
1353+
#define CTRE_CNTTP_COMPILER_CHECK CTLL_CNTTP_COMPILER_CHECK
13441354

13451355
#if __GNUC__ > 9
13461356
#if __has_cpp_attribute(likely)
@@ -4790,7 +4800,7 @@ template <typename... Ts> constexpr bool is_range<multi_subject_range<Ts...>> =
47904800

47914801
}
47924802

4793-
#if __cpp_lib_ranges >= 201911
4803+
#if defined __cpp_lib_ranges && __cpp_lib_ranges >= 201911
47944804
namespace std::ranges {
47954805

47964806
template <typename... Ts> inline constexpr bool enable_borrowed_range<::ctre::regex_range<Ts...>> = true;

single-header/ctre.hpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ template <size_t N> struct fixed_string {
274274
bool correct_flag{true};
275275
template <typename T> constexpr fixed_string(const T (&input)[N+1]) noexcept {
276276
if constexpr (std::is_same_v<T, char>) {
277-
#if CTRE_STRING_IS_UTF8
277+
#ifdef CTRE_STRING_IS_UTF8
278278
size_t out{0};
279279
for (size_t i{0}; i < N; ++i) {
280280
if ((i == (N-1)) && (input[i] == 0)) break;
@@ -441,12 +441,6 @@ template <size_t N> fixed_string(fixed_string<N>) -> fixed_string<N>;
441441

442442
}
443443

444-
#if CTLL_CNTTP_COMPILER_CHECK
445-
#define CTLL_FIXED_STRING ctll::fixed_string
446-
#else
447-
#define CTLL_FIXED_STRING const auto &
448-
#endif
449-
450444
#endif
451445

452446
#ifndef CTLL__TYPE_STACK__HPP
@@ -457,7 +451,23 @@ template <size_t N> fixed_string(fixed_string<N>) -> fixed_string<N>;
457451

458452
#include <type_traits>
459453

460-
#define CTLL_CNTTP_COMPILER_CHECK (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L) || ((__cpp_nontype_template_args >= 201411L) && (__clang_major__ >= 12) && !__apple_build_version__))
454+
#if defined __cpp_nontype_template_parameter_class
455+
#define CTLL_CNTTP_COMPILER_CHECK 1
456+
#elif defined __cpp_nontype_template_args
457+
#if __cpp_nontype_template_args >= 201911L
458+
#define CTLL_CNTTP_COMPILER_CHECK 1
459+
#elif __cpp_nontype_template_args >= 201411L
460+
#if defined __clang_major__ && __clang_major__ >= 12
461+
#if !defined __apple_build_version__ || !__apple_build_version__
462+
#define CTLL_CNTTP_COMPILER_CHECK 1
463+
#endif
464+
#endif
465+
#endif
466+
#endif
467+
468+
#ifndef CTLL_CNTTP_COMPILER_CHECK
469+
#define CTLL_CNTTP_COMPILER_CHECK 0
470+
#endif
461471

462472
#ifdef _MSC_VER
463473
#define CTLL_FORCE_INLINE __forceinline
@@ -1337,7 +1347,7 @@ struct pcre {
13371347
#ifndef CTRE__UTILITY__HPP
13381348
#define CTRE__UTILITY__HPP
13391349

1340-
#define CTRE_CNTTP_COMPILER_CHECK (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L) || ((__cpp_nontype_template_args >= 201411L) && (__clang_major__ >= 12) && !__apple_build_version__))
1350+
#define CTRE_CNTTP_COMPILER_CHECK CTLL_CNTTP_COMPILER_CHECK
13411351

13421352
#if __GNUC__ > 9
13431353
#if __has_cpp_attribute(likely)
@@ -4787,7 +4797,7 @@ template <typename... Ts> constexpr bool is_range<multi_subject_range<Ts...>> =
47874797

47884798
}
47894799

4790-
#if __cpp_lib_ranges >= 201911
4800+
#if defined __cpp_lib_ranges && __cpp_lib_ranges >= 201911
47914801
namespace std::ranges {
47924802

47934803
template <typename... Ts> inline constexpr bool enable_borrowed_range<::ctre::regex_range<Ts...>> = true;

0 commit comments

Comments
 (0)