Repository navigation
fix(audio): add #ifndef guards to vibe.h for PCH-safe inclusion - #2325
Merged
Merged
Conversation
On Windows builds, the include path for vibe.h is sometimes presented with mixed slashes (e.g. "fastled6/./src\fl/audio/detector/vibe.h"), which can defeat `#pragma once`'s file-identity check. When vibe.h is included both via audio_processor.h and via tests/fl/audio/detector/vibe.hpp, the resulting translation unit sees VibeLevels and Vibe defined twice and fails with a redefinition error. Fix: add a classic `#ifndef FL_AUDIO_DETECTOR_VIBE_H` guard alongside the existing `#pragma once`. This matches the belt-and-suspenders pattern already used in audio_processor.h and is content-based (path-agnostic), so it deduplicates regardless of how the include path is spelled. Verified with `bash test --cpp`: 299/299 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAn include guard ( Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
zackees
added a commit
that referenced
this pull request
Apr 18, 2026
…ibling -I spellings The test include args were chaining `meson.project_source_root() / '.' / 'src'` which produces `C:/.../fastled6/./src` with a `/./` in the middle of the path. Every other meson file uses `meson.project_source_root() / 'src'` directly, producing `C:/.../fastled6/src` — a cleaner spelling. When the test DLL links against fastled_lib / crash_handler_lib, Meson ends up putting both spellings of the same directory on the compile line as distinct -I flags. Clang keys #pragma once on the resolved path string, so two spellings of the same directory can defeat the deduplication even though they refer to the same file. This change aligns the test -I spelling with the rest of the codebase (ci/meson/native/meson.build lines 438, 469, 524 and examples/meson.build line 172 all already use the clean spelling). Note: this is a cleanup, not a #pragma once fix. The redefinition error seen when vibe.h is included via both audio_processor.h and tests/fl/audio/detector/vibe.hpp is a deeper PCH+clang issue on Windows toolchains; the defensive ifndef guard added in #2325 is the working fix. This PR just removes an unnecessary path inconsistency so the overall -I surface area is smaller and any future investigation is working from clean paths. Verified: bash test --cpp all 299/299 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 18, 2026
refactor(tests): drop _project_root_fwd indirection; align test -I paths with rest of codebase
#2327
Merged
zackees
added a commit
that referenced
this pull request
Apr 18, 2026
On Windows, Meson's `include_directories()` propagates `-I` flags using native backslash + relative-path spellings (e.g. `-I..\..\src\platforms\stub`). Clang keys `#pragma once` deduplication on the raw resolved path string — if the same directory reaches a translation unit via two different spellings (forward slash vs backslash, absolute vs relative), the header appears to be two different files and `#pragma once` is silently defeated, producing double-definition errors (#2324, #2325). This change ensures every `-I` flag we generate is absolute + forward-slash + spelled identically everywhere: * Add canonical `path_norm_*` -I args in ci/meson/shared/meson.build (path_norm_I_root, path_norm_I_src, path_norm_I_tests, path_norm_I_stub). Every consumer meson.build references these instead of redeclaring. * Replace every project-wide `include_directories(...)` consumer (`include_directories: [src_dir, stub_dir, ...]`) with explicit absolute cpp_args. This stops Meson from injecting relative backslash `-I` flags into the propagated compile lines. * For per-example discovered include dirs, build absolute forward-slash `-I` args from the discovered relative path via the `/` operator and the canonical `path_norm_root` prefix, replacing the previous `include_directories(inc_dir_fixed)` call. * Remove the `#ifndef FL_AUDIO_DETECTOR_VIBE_H` belt-and-suspenders guard added in #2325. With all `-I` flags normalized, `#pragma once` alone is sufficient. Verified with `bash test --cpp`: 300/300 tests pass. * Add ci/tests/test_meson_include_paths.py — a CI check that parses `.build/meson*/compile_commands.json` after setup and fails if any non-Meson-auto `-I` flag contains a backslash or is not absolute. Fixes #2328. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
4 tasks done
zackees
added a commit
that referenced
this pull request
Apr 18, 2026
On Windows, Meson's `include_directories()` propagates `-I` flags using native backslash + relative-path spellings (e.g. `-I..\..\src\platforms\stub`). Clang keys `#pragma once` deduplication on the raw resolved path string — if the same directory reaches a translation unit via two different spellings (forward slash vs backslash, absolute vs relative), the header appears to be two different files and `#pragma once` is silently defeated, producing double-definition errors (#2324, #2325). This change ensures every `-I` flag we generate is absolute + forward-slash + spelled identically everywhere: * Add canonical `path_norm_*` -I args in ci/meson/shared/meson.build (path_norm_I_root, path_norm_I_src, path_norm_I_tests, path_norm_I_stub). Every consumer meson.build references these instead of redeclaring. * Replace every project-wide `include_directories(...)` consumer (`include_directories: [src_dir, stub_dir, ...]`) with explicit absolute cpp_args. This stops Meson from injecting relative backslash `-I` flags into the propagated compile lines. * For per-example discovered include dirs, build absolute forward-slash `-I` args from the discovered relative path via the `/` operator and the canonical `path_norm_root` prefix, replacing the previous `include_directories(inc_dir_fixed)` call. * Remove the `#ifndef FL_AUDIO_DETECTOR_VIBE_H` belt-and-suspenders guard added in #2325. With all `-I` flags normalized, `#pragma once` alone is sufficient. Verified with `bash test --cpp`: 300/300 tests pass. * Add ci/tests/test_meson_include_paths.py — a CI check that parses `.build/meson*/compile_commands.json` after setup and fails if any non-Meson-auto `-I` flag contains a backslash or is not absolute. Fixes #2328. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
that referenced
this pull request
Apr 18, 2026
… (#2332) On Windows, Meson's `include_directories()` propagates `-I` flags using native backslash + relative-path spellings (e.g. `-I..\..\src\platforms\stub`). Clang keys `#pragma once` deduplication on the raw resolved path string — if the same directory reaches a translation unit via two different spellings (forward slash vs backslash, absolute vs relative), the header appears to be two different files and `#pragma once` is silently defeated, producing double-definition errors (#2324, #2325). This change ensures every `-I` flag we generate is absolute + forward-slash + spelled identically everywhere: * Add canonical `path_norm_*` -I args in ci/meson/shared/meson.build (path_norm_I_root, path_norm_I_src, path_norm_I_tests, path_norm_I_stub). Every consumer meson.build references these instead of redeclaring. * Replace every project-wide `include_directories(...)` consumer (`include_directories: [src_dir, stub_dir, ...]`) with explicit absolute cpp_args. This stops Meson from injecting relative backslash `-I` flags into the propagated compile lines. * For per-example discovered include dirs, build absolute forward-slash `-I` args from the discovered relative path via the `/` operator and the canonical `path_norm_root` prefix, replacing the previous `include_directories(inc_dir_fixed)` call. * Remove the `#ifndef FL_AUDIO_DETECTOR_VIBE_H` belt-and-suspenders guard added in #2325. With all `-I` flags normalized, `#pragma once` alone is sufficient. Verified with `bash test --cpp`: 300/300 tests pass. * Add ci/tests/test_meson_include_paths.py — a CI check that parses `.build/meson*/compile_commands.json` after setup and fails if any non-Meson-auto `-I` flag contains a backslash or is not absolute. Fixes #2328. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.
Classic #ifndef guards alongside existing #pragma once. Works around a Clang-on-Windows PCH dedup quirk that caused VibeLevels/Vibe redefinition errors when vibe.h was pulled in via the test PCH (FastLED.h → audio_processor.h → vibe.h) and also directly by the standalone tests/fl/audio/detector/vibe.cpp. Confirmed fix with clean rebuild: all audio tests pass.
Summary by CodeRabbit