Skip to content

Fix ambiguous namespace resolution for Sample in bvar::detail#525

Open
day253 wants to merge 1 commit intobaidu:masterfrom
day253:fix-bvar-detail-sample-namespace
Open

Fix ambiguous namespace resolution for Sample in bvar::detail#525
day253 wants to merge 1 commit intobaidu:masterfrom
day253:fix-bvar-detail-sample-namespace

Conversation

@day253
Copy link

@day253 day253 commented Mar 15, 2026

Summary

  • Fix compilation error in src/braft/util.cpp caused by ambiguous namespace resolution
  • Inside namespace bvar::detail, the qualified name detail::Sample<Stat> resolves to bvar::detail::detail::Sample<Stat> which does not exist
  • Changed to unqualified Sample<Stat> which correctly resolves to bvar::detail::Sample<Stat>

Background

This issue was discovered when updating the brpc port to 1.16.0 in vcpkg (microsoft/vcpkg#50466). Changes to bvar's internal namespace structure in brpc >= 1.16.0 exposed this pre-existing ambiguity, causing braft to fail to compile.

Changes

--- a/src/braft/util.cpp
+++ b/src/braft/util.cpp
@@ -47,7 +47,7 @@ namespace detail {
 typedef PercentileSamples<1022> CombinedPercentileSamples;
 
 static int64_t get_window_recorder_qps(void* arg) {
-    detail::Sample<Stat> s;
+    Sample<Stat> s;
     static_cast<RecorderWindow*>(arg)->get_span(1, &s);

Test Plan

  • Verified braft compiles successfully against brpc 1.16.0 with this fix (via vcpkg CI on all 15 platforms: arm64_android, arm64_linux, arm64_osx, arm64_windows, arm64_windows_static_md, arm_neon_android, x64_android, x64_linux, x64_windows, x64_windows_release, x64_windows_static, x64_windows_static_md, x86_windows)
  • See: [brpc] Update to 1.16.0 microsoft/vcpkg#50466

Made with Cursor

Inside `namespace bvar::detail`, the qualified name `detail::Sample<Stat>`
resolves to `bvar::detail::detail::Sample<Stat>`, which does not exist.
Since the code is already within `namespace bvar::detail`, use the
unqualified `Sample<Stat>` which correctly resolves to
`bvar::detail::Sample<Stat>`.

This fixes compilation errors when building braft against brpc >= 1.16.0,
where changes to bvar's internal namespace structure exposed this
pre-existing ambiguity.

Made-with: Cursor
@day253
Copy link
Author

day253 commented Mar 15, 2026

Hi, this PR fixes the compilation error reported in #524 (braft 1.1.2 incompatibility with brpc 1.16.0).

The fix has been verified across 15 platforms via vcpkg CI: microsoft/vcpkg#50466

@PFZheng @ehds @isaacwong96 Could you please help review this small one-line fix when you have a chance? Thank you! 🙏

cc @simaocat — this should resolve the issue you reported in #524.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant