fix(wayland): 导出模块够不着的八个 static inline 函数 - #330
Merged
Conversation
`static inline` 是内部链接,C++ 禁止从模块导出。这个 fork 一直知道这个坑 ——
它为 wayland-scanner 生成的包装专门做了 `inline` 副本 —— 但漏掉了两个手写头:
wayland-server-core.h wl_signal_init/_add/_get/_emit -> .server
wayland-util.h wl_fixed_to/from_double/int -> .client
这不是边角。每一次 wlroots 监听注册都是 wl_signal_add(&x->events.y, &l),所以
**走模块路线写不了合成器**;wl_fixed_t 是协议里每个亚像素坐标的载体(指针移动、
触摸、数位板),所以**处理不了输入事件**。
⚠️ 一直没发现,因为这个包的测试从没调用过其中任何一个。缺口是从**外面**被问出
来的 —— 一个最小 wlroots 合成器编不过。同一类问题在 freedesktop.cairo(少
cairo_t)和 displayinfo(少 295 个枚举量)上都出现过,发现方式完全一样:
**自己的测试问不出来,别的包在真实用途里能。**
索引示例现在真的调用这八个 —— 再塌陷就是编译错误。
资产:wayland-1.26.0-mcpp4.tar.gz,sha256 9bce2cc0…,两个镜像一致。
六个描述符同步。gcc 16.1 / llvm 22.1 双绿。
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.
缺口
static inline是内部链接,C++ 禁止从模块导出。这个 fork 一直知道这个坑 —— 它为 wayland-scanner 生成的包装专门做了inline副本,注释里写得很清楚 —— 但漏掉了两个手写头文件里的:wayland-server-core.hwl_signal_init/_add/_get/_emitfreedesktop.wayland.serverwayland-util.hwl_fixed_to/from_double/intfreedesktop.wayland.client不是边角:每一次 wlroots 监听注册都是
wl_signal_add(&x->events.y, &l),所以走模块路线写不了合成器;wl_fixed_t是协议里每个亚像素坐标的载体(指针移动、触摸、数位板),所以处理不了输入事件。这个包的测试从没调用过其中任何一个。 缺口是从外面被问出来的 —— 我写了一个最小 wlroots 合成器,编不过:
同一类问题在
freedesktop.cairo(少cairo_t)和displayinfo(少 295 个枚举量)上都出现过,发现方式完全一样:自己的测试问不出来,别的包在真实用途里能。做法,以及两个只有 clang 会说的坑
原来的
inline副本手法在这里不适用:这两个头必须进 global module fragment(其它声明要用它们的类型),所以static定义已经可见,purview 里同名定义就是重定义。做法是先把 static 原件改名让开,再用真名定义并导出。struct wl_signal *不能写。 elaborated-type-specifier 会在模块里重新声明该类型:declaration of 'wl_signal' in module ... follows declaration in the global module。GCC 静默接受。wl_fixed_*不能放进freedesktop.wayland.util。 那个模块是和头文件配对设计的(只出宏和模板,零个using ::),它自己的测试就写着#include <wayland-util.h>+import。加同名实体会让每次调用call to 'wl_fixed_from_int' is ambiguous。也没有同时放进 server —— 两个模块各自的实体,对同时 import 两者的 TU 一样是二义。三个模块同时 import 已实测,两条工具链都通过。
验证
tests/examples/wayland现在真的调用这八个 —— 再塌陷就是编译错误wayland-1.26.0-mcpp4.tar.gz,sha2569bce2cc0…,两个镜像一致,六个描述符同步