有我的 project.gpr 文件:
project Test is
Project_Source_Dirs := ("Dir1")
& ("src")
& ("../../lib_all");
for Object_Dir is "lib";
for Main use ("Main_file.adb");
for Languages use ("Ada");
for Source_Dirs use Project_Source_Dirs & project'Object_Dir;
-- [...]
end Test;
Run Code Online (Sandbox Code Playgroud)
有我的“../../lib_all”文件夹:
lib_all
|- file1.adb
|- file1.ads
|- file2.adb
|- file2.ads
|- file3.adb
|- file3.ads
|- file4.adb
|- file4.ads
Run Code Online (Sandbox Code Playgroud)
我只想使用 file3,如何修改我的 .gpr 文件以便每次都不编译所有其他文件?
我正在尝试在 ADA 中创建一个包。我有三个文件,adb(主程序)、ads(包)和 adb(主体包)。我看不出我的主文件和包文件有任何问题。但是,在我的 body 包中,我无法编写将 P1 和 P2 的值相加然后返回其值的函数。
我的主程序:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Price_Handling; use Price_Handling;
procedure Test_Price_Plus is
P1, P2 : Price_Type;
begin
P1.Dollar:= 19;
P1.Cents:= 50;
P2 := (Dollar => 10, Cents=> 0);
Put("P1 is ");
Put(P1);
New_Line;
Put("P2 is ");
Put(P2);
New_Line;
Put("If we add P1 and P2, then we get: ");
Put(P1 + P2);
New_Line;
end Test_Price_Plus;
Run Code Online (Sandbox Code Playgroud)
我的包裹:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
package Price_Handling is …Run Code Online (Sandbox Code Playgroud)