comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Multiple procedures in the same adb file?
Date: Sun, 11 Jan 2015 13:04:47 -0700
Date: 2015-01-11T13:04:47-07:00	[thread overview]
Message-ID: <m8ul04$ht3$1@dont-email.me> (raw)
In-Reply-To: <5fc3a42d-f922-4e34-ab30-59613b980fb6@googlegroups.com>

On 01/11/2015 11:37 AM, John Smith wrote:
> 
> ===============================================================================
> procedure a_test(A, B : Integer; C : out Integer) is
> begin
>   C := A + B;
> end a_test;
> 
> procedure test_procedure is
>   output : Integer;
> begin
>   a_test(23, 34, output);
> end test_procedure;
> ===============================================================================
> 
> And this is the compilation error that I got:
> ===============================================================================
> % gnatmake -g test_procedure.adb
> gcc -c -g test_procedure.adb
> test_procedure.adb:16:01: end of file expected, file can have only one compilation unit
> gnatmake: "test_procedure.adb" compilation error
> ===============================================================================

GNAT only allows a single compilation unit per file. A compilation unit is a
subprogram declaration, subprogram body, package specification, or pkg body. You
have 2 subprogram bodies in a single file, so GNAT rejects it. Some other
compilers have no problem with multiple compilation units in a single file.

for a simple program like this you probably want to nest A_Test in Test_Procedure:

procedure Test_Procedure is
  procedure A_Test (A : in Integer; B : in Integer; C : out Integer) is
  begin -- A_Test
    C := A + B;
  end A_Test;

  Output : Integer;
begin -- Test_Procedure
  A_Test (A => 23, B => 34, C => Output);
end Test_Procedure;

-- 
Jeff Carter
"It's all right, Taggart. Just a man and a horse being hung out there."
Blazing Saddles
34

      parent reply	other threads:[~2015-01-11 20:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-11 18:37 Multiple procedures in the same adb file? John Smith
2015-01-11 19:05 ` John Smith
2015-01-11 19:51 ` Robert A Duff
2015-01-11 20:38   ` John Smith
2015-01-11 21:02     ` Robert A Duff
2015-01-11 21:51       ` John Smith
2015-01-12  0:53         ` Robert A Duff
2015-01-12  0:55         ` Robert A Duff
2015-01-13  0:11       ` Randy Brukardt
2015-01-11 21:38   ` Niklas Holsti
2015-01-12  0:53     ` Robert A Duff
2015-01-12  9:01       ` J-P. Rosen
2015-01-12 14:57         ` Robert A Duff
2015-01-13  0:09           ` Randy Brukardt
2015-01-12  0:55     ` Robert A Duff
2015-01-11 20:04 ` Jeffrey Carter [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox