fix(field_encoder): replace __builtin_expect with C++20 [[likely]]/[[unlikely]] for MSVC#115
Merged
Merged
Conversation
…iltin_expect __builtin_expect is a GCC/Clang builtin that MSVC does not provide. The hint in the always-compiled NaN fallback path (and the SIMD fast path under /arch:AVX) made FieldEncoderFloatN_Lossy::encode fail to compile under MSVC. cloudini already requires C++20, so the standard [[likely]]/[[unlikely]] attributes are an equivalent, fully portable replacement — no behavior change on GCC/Clang, and the library now compiles under MSVC. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
facontidavide
added a commit
that referenced
this pull request
Jun 4, 2026
Bump cloudini_lib + cloudini_ros (package.xml) and the Foxglove extension (package.json/lock) to 1.2.2, with CHANGELOG entries. The library change in this release is the MSVC __builtin_expect -> [[likely]]/[[unlikely]] fix (#115); the rest are dev-dependency bumps. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace
__builtin_expectwith the C++20[[likely]]/[[unlikely]]attributes inFieldEncoderFloatN_Lossy::encode(cloudini_lib/src/field_encoder.cpp).Why
__builtin_expectis a GCC/Clang builtin; MSVC doesn't provide it. The hint in the always-compiled NaN fallback path breaks every MSVC build (the one in the SIMD fast path additionally breaks under/arch:AVX). This is the only blocker preventingcloudini_libfrom compiling under MSVC — the rest of the library is already portable:intrinsics.hppfalls back to scalar when__SSE__/__AVX__aren't defined, and the contrib headers (unordered_dense.h,nanocdr.hpp,span.hpp) are MSVC-safe.Since cloudini already requires C++20 (
check_min_cppstd(20)),[[likely]]/[[unlikely]]is an equivalent, fully portable replacement with no behavior change on GCC/Clang.Testing
cloudini_librebuilds clean on GCC 13 (Linux) — no regression.is_msvcConanInvalidConfigurationgate is being removed separately).Context
Surfaced while consuming cloudini from PlotJuggler 4, whose Windows CI failed at
conan installon cloudini's MSVC rejection. This is the upstream code fix that makes MSVC support real.🤖 Generated with Claude Code