2
我试图编译这段代码:建筑,当我得到这个错误https://github.com/RanaExMachina/ada-fuse如何在Ada中显式指定泛型类型的大小?
不幸的是:
fuse-system.ads:147:04: size clause not allowed for variable length type
这似乎是因为它的代码试图设置记录的大小是一个问题,具有通用类型作为条目。这似乎是一个新的错误,因为开发人员在2.5年前撰写这个问题时没有遇到这个问题。不幸的是,他不能在短时间内帮助我,但我必须让图书馆去。然而,在解决这个问题上我有点无奈。
基本上我觉得我不得不告诉gnat这个类型会有多大,与gnat相信的是相反的先验知识:它是一种访问类型。在record
或泛型类型定义中。
相关的部分是:
fuse-main.ads:
package Fuse.Main is
package IO is
new Ada.Direct_IO (Element_Type);
type File_Access is access IO.File_Type;
fuse-system.ads:
generic
type File_Access is private;
package Fuse.System is
...
type File_Info_Type is record
Flags : Flags_Type;
Fh_Old : Interfaces.C.unsigned_long;
Writepage : Interfaces.C.int;
Direct_IO : Boolean := True;
Keep_Cache : Boolean := True;
Flush : Boolean := True;
Nonseekable : Boolean := True;
Fh : File_Access;
Lock_Owner : Interfaces.Unsigned_64;
end record;
type File_Info_Access is access File_Info_Type;
pragma Convention (C, File_Info_Type);
for File_Info_Type'Size use 32*8;
我蚊蚋的版本是:4.9.2-1(Debian的杰西)
我不知道它是否有意义(或者是有帮助的话),使文件不完整类型在这里。我想我会尝试,并在通用本身中定义访问类型,以便泛型可以在声明实际文件的相同公共部分实例化。 – manuBriot
@manuBriot,我已经包含了你的建议。 –