From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Multiple procedures in the same adb file? Date: Sun, 11 Jan 2015 13:04:47 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <5fc3a42d-f922-4e34-ab30-59613b980fb6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sun, 11 Jan 2015 20:04:21 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="9d3e8459fcff41835e7b68eb9f2a14bb"; logging-data="18339"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZK18CPbxwMD3ZZWUSE9rF13Ub//H1Nho=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: <5fc3a42d-f922-4e34-ab30-59613b980fb6@googlegroups.com> Cancel-Lock: sha1:WOkIsIs6p2fIsU+EstASuRj1c+s= Xref: news.eternal-september.org comp.lang.ada:24537 Date: 2015-01-11T13:04:47-07:00 List-Id: 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