Skip to content

fix(audio): add ifndef guard to vibe.h so pragma once survives mixed-slash include paths - #2324

Closed
zackees wants to merge 1 commit into
masterfrom
fix-vibe-header-guard
Closed

zackees wants to merge 1 commit into
masterfrom
fix-vibe-header-guard

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add classic #ifndef FL_AUDIO_DETECTOR_VIBE_H guard alongside the existing #pragma once in src/fl/audio/detector/vibe.h.
  • Matches the belt-and-suspenders pattern already used in src/fl/audio/audio_processor.h.

Background

On Windows builds, clang sometimes presents the include path for vibe.h with mixed slashes:

C:/Users/niteris/dev/fastled6/./src\fl/audio/detector/vibe.h

When vibe.h is pulled in through two different paths in the same translation unit — once via audio_processor.h (line 9) and once via tests/fl/audio/detector/vibe.hpp (line 6) — #pragma once's file-identity check can fail to deduplicate. The TU then sees VibeLevels and Vibe defined twice and fails with:

error: redefinition of 'VibeLevels'
error: redefinition of 'Vibe'
note: included multiple times, additional include site here

Adding an #ifndef guard is content-based and path-agnostic, so it deduplicates regardless of how the include path is spelled. This mirrors what audio_processor.h already does.

Why this matters

Master CI has been failing on this error. Reproduced locally on Windows; the guard fixes it.

Test plan

  • bash test vibe --cpp — vibe unit test passes
  • bash test --cpp — all 299 C++ unit tests + examples pass
  • CI green

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Internal code maintenance improvements.

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]>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 89e8acf4-d6eb-49fd-a267-6fb928ac31f6

📥 Commits

Reviewing files that changed from the base of the PR and between 9528888 and eca191e.

📒 Files selected for processing (1)
  • src/fl/audio/detector/vibe.h

📝 Walkthrough

Walkthrough

Added a conventional include guard to the header file using preprocessor directives (#ifndef, #define, #endif) to prevent multiple inclusion during compilation. No code logic or declarations were modified.

Changes

Cohort / File(s) Summary
Include Guard Addition
src/fl/audio/detector/vibe.h
Added standard C++ include guard (FL_AUDIO_DETECTOR_VIBE_H) around the entire header file to prevent multiple inclusion.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A guard stands tall, both wise and keen,
No double files will now be seen!
The header wrapped in preprocessor care,
Safe from inclusion's tangled snare. 🐰✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-vibe-header-guard

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees zackees closed this Apr 18, 2026
@zackees

zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member Author

this is the wrong fxi, the right fix is normalization of the paths that clang is presented with FROM us

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
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]>
@zackees
zackees deleted the fix-vibe-header-guard branch August 30, 2026 22:22
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