I am trying to get my head around OOP in Ada. In order to do so, I need to understand how to name, compile and link package files with gnatmake.
This website (http://www.infres.enst.fr/~pautet/Ada95/chap22.htm) has good examples, but I don't understand how to compile the various bits of the program.
I am looking at e_c22_p2.ada and e_c22_p3.ada. From these I created a file called Conveyance1.ads and added the content of e_c22_p2 into this, and a file called Vehicle1.adb and added the content of e_c22_p3.ada in there. I used gnatmake Vehicle1.adb, but there are compilation errors.
e_c22_p2.ada contains:
-- Chapter 22 - Program 2 package Conveyance1 is -- This is a very simple transportation type. type TRANSPORT is record Wheels : INTEGER; Weight : FLOAT; end record; procedure Set_Values(Vehicle_In : in out TRANSPORT; Wheels_In : INTEGER; Weight_In : FLOAT); function Get_Wheels(Vehicle_In : TRANSPORT) return INTEGER; function Get_Weight(Vehicle_In : TRANSPORT) return FLOAT; -- This CAR type extends the functionality of the TRANSPORT type. type CAR is new TRANSPORT; function Tire_Loading(Vehicle_In : CAR) return FLOAT; end Conveyance1; package body Conveyance1 is -- Subprograms for the TRANSPORT record type. procedure Set_Values(Vehicle_In : in out TRANSPORT; Wheels_In : INTEGER; Weight_In : FLOAT) is begin Vehicle_In.Wheels := Wheels_In; Vehicle_In.Weight := Weight_In; end Set_Values; function Get_Wheels(Vehicle_In : TRANSPORT) return INTEGER is begin return Vehicle_In.Wheels; end Get_Wheels; function Get_Weight(Vehicle_In : TRANSPORT) return FLOAT is begin return Vehicle_In.Weight; end Get_Weight; -- Subprogram for the CAR record type. function Tire_Loading(Vehicle_In : CAR) return FLOAT is begin return Vehicle_In.Weight / FLOAT(Vehicle_In.Wheels); end Tire_Loading; end Conveyance1; -- Results of execution -- -- (This package cannot be executed alone.)
gnatchopon the source files (e_c22_p2.adaetc) to create the source files that GNAT expects.