fix: include system headers outside extern "C" #1125

Closed
ameliabarnabyhub wants to merge 1 commit from fix/extern-c-system-headers-1122 into dev
ameliabarnabyhub commented 2026-08-16 01:05:16 -05:00 (Migrated from github.com)

Fixes #1122

Summary

  • System headers must not be included inside an extern "C" region (can force C linkage onto C++ declarations, e.g. arm_neon.h on aarch64 GCC 17).
  • Add XXH_EXTERNC_PAUSE / XXH_EXTERNC_RESUME helpers and wrap all system #includes so they are processed outside extern "C".

Test plan

  • C++ compile that previously failed with arm_neon.h conflicting C vs C++ linkage now succeeds.
  • Existing xxHash C and C++ builds / tests still pass.
Fixes #1122 ## Summary - System headers must not be included inside an `extern "C"` region (can force C linkage onto C++ declarations, e.g. `arm_neon.h` on aarch64 GCC 17). - Add `XXH_EXTERNC_PAUSE` / `XXH_EXTERNC_RESUME` helpers and wrap all system `#include`s so they are processed outside `extern "C"`. ## Test plan - [ ] C++ compile that previously failed with `arm_neon.h` conflicting C vs C++ linkage now succeeds. - [ ] Existing xxHash C and C++ builds / tests still pass.
Cyan4973 commented 2026-09-14 13:02:21 -05:00 (Migrated from github.com)

We should first have a CI test that makes the problem visible.
Let me see what I can do.

edit : see #1129

We should first have a CI test that makes the problem visible. Let me see what I can do. _edit_ : see #1129
Cyan4973 commented 2026-09-14 13:23:24 -05:00 (Migrated from github.com)

Thanks for the PR,
the proposed solution works, but it also introduces preprocessor complexity, detrimental to future maintenance.

Superseded by #1129, more specifically 959ca516f3, which fixes the same issue in a simpler way.

Thanks for the PR, the proposed solution works, but it also introduces preprocessor complexity, detrimental to future maintenance. Superseded by #1129, more specifically 959ca516f356d0255e7166d3f8fe049b0c532837, which fixes the same issue in a simpler way.

Pull request closed

Sign in to join this conversation.
No description provided.