Skip to content

fix: Rename template parameter BLOCK_SIZE to avoid macro conflict#127

Merged
liuq19 merged 1 commit intobytedance:masterfrom
tanghaoth90:rename_block_size
Feb 13, 2026
Merged

fix: Rename template parameter BLOCK_SIZE to avoid macro conflict#127
liuq19 merged 1 commit intobytedance:masterfrom
tanghaoth90:rename_block_size

Conversation

@tanghaoth90
Copy link
Contributor

The template parameter BLOCK_SIZE used in internal/arch/common/unicode_common.h conflicts with a common macro of the same name defined in system headers like <linux/fs.h> (on Linux/Android). This causes compilation errors when <sonic/sonic.h> is included after such headers.

This pull request renames the template parameter to prevent this macro pollution, improving the library's robustness and compatibility in various build environments.

Changes

  • Renamed the template parameter BLOCK_SIZE in internal/arch/common/unicode_common.h.
  • Updated all internal usages of this template parameter to reflect the new name.

Reproduce

The fix has been verified by building the following minimal reproducible example, which now compiles successfully:

// g++ -I./include -mpclmul -march=haswell --std=c++11 -O3 thisfile.cpp
#include <linux/fs.h>
#include <sonic/sonic.h>

int main() {
    return 0;
}

The compilation error message is shown below:

.../include/sonic/internal/arch/neon/../common/unicode_common.h:271:18: error: expected ')'
.../sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/fs.h:29:21: note: expanded from macro 'BLOCK_SIZE'
.../include/sonic/internal/arch/neon/../common/unicode_common.h:271:18: note: to match this '('
.../sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/fs.h:29:20: note: expanded from macro 'BLOCK_SIZE'

- Renamed the template parameter BLOCK_SIZE to SONIC_BLOCK_SIZE in internal/arch/common/unicode_common.h.
- Updated all internal usages of this template parameter to reflect the new name.
@liuq19 liuq19 merged commit a1cae94 into bytedance:master Feb 13, 2026
18 of 23 checks passed
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.04%. Comparing base (4250a05) to head (04e6acc).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
+ Coverage   74.79%   76.04%   +1.25%     
==========================================
  Files          21       22       +1     
  Lines        2436     2680     +244     
  Branches      667      750      +83     
==========================================
+ Hits         1822     2038     +216     
+ Misses        297      106     -191     
- Partials      317      536     +219     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants