没有看到terminal_interface-curses-mouse.ads 中的相关声明,我无法确定。但是,我怀疑Event_Mask 的大小存在冲突。当我尝试它时,这条线被硬连线到terminal_interface-curses-mouse.ads.m4:
type Event_Mask is new Interfaces.C.unsigned_long;
但是Mouse_Event 的 rep 子句定义了 Bstate,类型为 Event_Mask,如下所示:
Bstate at 0 range 128 .. 159;
这是基于<ncurses.h> 中mmask_t 的类型,即我系统上的unsigned。如果unsigned_long是64位,C的unsigned类型是32,编译器会报错。
如果发生这种情况,请尝试手动将 type Event_Mask 行更改为
type Event_Mask is new Interfaces.C.unsigned_long range 0 .. 2**32 - 1;
for Event_Mask'Size use 32;
或
type Event_Mask is new Interfaces.C.unsigned_long range 0 .. 2**32 - 1 with Size => 32;
这有望避免“尺寸太小”的问题,而不会在其余代码中引起任何新的类型冲突。但是,我还没有测试过。
这应该报告为一个错误,因为 Event_Mask 的类型不应该像这样硬连线。
编辑:直到后来我才意识到,由于 Event_Mask 是派生类型,因此从 Interfaces.C.unsigned_long 派生它并具有范围约束没有任何好处。假设mmask_t 在.h 文件中被定义为unsigned,它应该同样有效
type Event_Mask is new Interfaces.C.unsigned;
您仍然需要手动更改它,并且确实需要修复 .m4 文件和生成器以找出正确的类型,这就是为什么我认为这应该被视为 ncurses 中的一个错误。