ADA文件名与包名 [英] ADA File Names vs. Package Names

查看:144
本文介绍了ADA文件名与包名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了ADA程序,其中源文件名和包文件名不遵循默认的命名约定。 ADA对我来说是新手,所以我可能缺少一些简单的东西,但在《 GNAT Pro用户指南》中看不到它。 (这个类似的问题对我没有帮助。)

I inherited an ADA program where the source file names and package file names don't follow the default naming convention. ADA is new to me, so I may be missing something simple, but I can't see it in the GNAT Pro User's Guide. (This similar question didn't help me.)

下面是几个示例:

File Name:    C_Comm_Config_S.Ada
Package Name: Comm_Configuration

File Name:    D_Bus_Buffers_S.Ada
Package Name: Bus_Buffers

我认为我已经整理出_S.Ada和_B.Ada,但是我在程序源中找不到任何内容,也没有建立显示包名称与其余文件名称之间的绑定的文件。

I think I have the _S.Ada and _B.Ada sorted out, but I can't find anything in the program source or build files that show the binding between the Package Name and the rest of the File Name.

当我编译不使用任何其他程序包的文件时,出现警告:文件名与单元名不匹配...这似乎是由于在这种特殊情况下,C_或D_的前缀。

When I compile a file that doesn't use any other packages, I get a warning: file name does not match unit name... This appears to be from the prefix of C_ or D_, in this particular case.

此外,我也不清楚前缀C_和D_在ADA中是否具有特殊含义,但是

Also, I'm not clear if the prefixes C_ and D_ have any special meaning in the context of ADA, but if it does, I'd like to know about it.

所以我似乎有两个问题,C_或D_的前缀,在某些情况下其余的文件名与软件包不匹配。

So I appear to have two issues, the Prefix of C_ or D_ and in some cases the rest of the file name doesn't match the package.

推荐答案

您可以使用 gnatname :请参见用户指南

我将子目录 a / d / 从ACATS测试套件复制到工作目录中,并创建了一个项目文件 p.gpr

I copied subdirectories a/ and d/ from the ACATS test suite to a working directory and created a project file p.gpr:

project p is
   for source_dirs use ("a", "d");
end p;

并运行昵称

gnatname -P p -d a -d d \*.ada

,导致编辑后的 p.gpr 和两个新文件 p_naming.gpr p_source_list.txt 。它们相当长,但是看起来像

which resulted in an edited p.gpr and two new files, p_naming.gpr and p_source_list.txt. These are rather long, but look like

p.gpr

with "p_naming.gpr";

project P is

   for Source_List_File use "p_source_list.txt";
   for Source_Dirs use ("a", "d");

   package Naming renames P_Naming.Naming;

end P;

p_naming.gpr

project P_Naming is

   for Source_Files use ();

   package Naming is
      for Body ("d4a004b") use "d4a004b.ada";
      for Body ("d4a004a") use "d4a004a.ada";
      for Body ("d4a002b") use "d4a002b.ada";
      ...
      for Body ("aa2010a_parent.boolean") use "aa2010a.ada" at 4;
      for Body ("aa2010a_parent") use "aa2010a.ada" at 3;
      for Spec ("aa2010a_parent") use "aa2010a.ada" at 2;
      for Spec ("aa2010a_typedef") use "aa2010a.ada" at 1;
      ...
      for Body ("a22006d") use "a22006d.ada";
      for Body ("a22006c") use "a22006c.ada";
      for Body ("a22006b") use "a22006b.ada";
    end Naming;

 end P_Naming;

对于Body( aa2010a_parent)使用3处的 aa2010a.ada; 用于更多

p_source_list.txt

a22006b.ada
a22006c.ada
a22006d.ada
a27003a.ada
a29003a.ada
...
d4a002b.ada
d4a004a.ada
d4a004b.ada

例如,在构建时,测试 d4a004b ,您必须使用文件名和后缀

When building, for example, test d4a004b, you have to use the file name and suffix:

gnatmake -P p d4a004b.ada

这篇关于ADA文件名与包名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆