Skip to content

Commit

Permalink
Only switch to absl::string_view implementation on Windows.
Browse files Browse the repository at this point in the history
On gcc and clang-based systems, std::string_view has the iterator
behave as expected by a lot of Verible code, being a const char*.

On windows c++ lib, the iterator is its own object, which does
not decay to const char*, so in that case we need to use the absl::
implementation which behaves like that.

We used to always change to the absl type, but in reality, we only
need to do that on Windows; adapt the abseil patch.

Longer term, we should remove the expectation of the iterator type,
but that requires access to a Windows machine to locally go through
a compile/fix loop.
  • Loading branch information
hzeller committed Dec 23, 2024
1 parent 2f99cdc commit f7aff2e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions bazel/absl.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
diff -uw -r a/absl/base/options.h b/absl/base/options.h
--- a/absl/base/options.h 2021-04-02 23:00:31.996584600 -0400
+++ b/absl/base/options.h 2021-04-02 23:01:07.506208600 -0400
@@ -154,7 +154,7 @@
diff --git a/absl/base/options.h b/absl/base/options.h
index 4b70446b..6a839d94 100644
--- a/absl/base/options.h
+++ b/absl/base/options.h
@@ -148,7 +148,13 @@
// absl::string_view is a typedef of std::string_view, use the feature macro
// ABSL_USES_STD_STRING_VIEW.

-#define ABSL_OPTION_USE_STD_STRING_VIEW 2

+#ifdef _WIN32
+// On Windows, the std::string_view iterator is not const char*, which
+// is the expectation in a lot of Verible code. Use absl-impl.
+#define ABSL_OPTION_USE_STD_STRING_VIEW 0

+#else
#define ABSL_OPTION_USE_STD_STRING_VIEW 2
+#endif

// ABSL_OPTION_USE_STD_VARIANT
//

0 comments on commit f7aff2e

Please sign in to comment.