Newbie question regarding Complier Directives

Marco Mastrocinque mmfive@netspace.net.au
Tue Aug 18 14:43:00 GMT 2009


Hi All,
          I’m new to the Ada programming language. I have downloaded GNAT
for the .NET Platform, and I’m having issues trying to get my main program
to use the Etc package which is in another file in the same subdirectory. I
assume I have to use complier directives. I’m not sure how is it is done in
GNAT. Please note I’m using MS Visual Studio 2005 as the IDE. I have listed
both files at the end of this email. Any assistance and perhaps some general
information in this area would be greatly appreciated. (Both files are in
the same subdirectory).
Thanks Marco Mastrocinque.   
Etc Pacakage 

with Ada.Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
package Etc is
      type My_Float is digits 7;
      type My_Integer is range -100000 .. +100000;
      
      package My_Float_IO is new Ada.Text_IO.Float_IO(My_Float);
      package     My_Integer_IO is new Ada.Text_IO.Integer_IO(My_Integer);
      package My_Elementary_Functions is new
Ada.Numerics.Generic_Elementary_Functions(My_Float);
end Etc;


Print_Roots pacakage (Main file)

with Ada.Text_IO, Etc;

procedure Print_Roots is
      use My_Float_IO, My_Integer_IO, My_Elementary_Functions;
      
      X: My_Float;
begin
      Put("Roots of various numbers");
    New_Line(2);
    loop
            Get(X);
            exit when X = 0.0;
            Put(" Root of "); Put(X); Put(" is ");
            if X < 0.0 then
                  Put("not calculable");
            else
                  Put(Sqrt(X));
            end if;
            New_Line;
    end loop;
    New_Line;
    Put("Program Finished");
    New_Line;
end Print_Roots;




More information about the Gcc-help mailing list