zephyr-sys: fix undefined __UINTxx_C macros under bindgen (#160)
Summary
On Ubuntu with
libclang-15, bindgen fails to process Zephyr’skernel/internal/mm.hbecause of recently-added file-scope#ifdirectives that referenceCONFIG_SRAM_BASE_ADDRESS. On boards whoseautoconf.hrenders that value via__UINT32_C(...), the preprocessor needs that macro defined before it reaches those#ifs.GCC and clang normally emit
__INTxx_C/__UINTxx_Cas compiler predefines, and Zephyr’s minimal libc<stdint.h>relies on that — the publicUINTxx_C(...)macros are simply redirected to the underscored variants on the GCC/clang branch. The libclang used by bindgen does not expose those predefines to its embedded preprocessor, so the#ifs inmm.hfail withfunction-like macro '__UINT32_C' is not definedand bindgen aborts.This pulls in
<stdint.h>at the top ofwrapper.hand explicitly defines the__INTxx_C/__UINTxx_Cset, guarded with#ifndefso that a toolchain which does surface them keeps precedence.Background
The triggering upstream change is Zephyr commit
eb805306186(“sca: Fix undefined behavior during preprocessing”), which movedmm.h‘s evaluation of those Kconfig values into file-scope#ifs. Before that, the macros only needed to be valid at the point of use, which happened to work without this shim.Test plan
west buildon an RP2040-class board (which exercises theCONFIG_SRAM_BASE_ADDRESS = __UINT32_C(0x20000000)path) under Ubuntu with the systemlibclang-15- Existing CI continues to pass on other host/board combinations
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号