comp.lang.ada
 help / color / mirror / Atom feed
From: "SteveD" <nospam_steved94@attbi.com>
Subject: Can the main procedure be a generic instance?
Date: Sat, 09 Nov 2002 17:54:44 GMT
Date: 2002-11-09T17:54:44+00:00	[thread overview]
Message-ID: <EZbz9.59081$sP2.19438@sccrnsc02> (raw)

I have defined a generic package gen_main as follows:

---------- File: gen_main.ads ----------
with ada.Text_io;
package Gen_Main is

generic
    number_of_times : integer;
procedure Gen;

end Gen_Main;
----------------------------------------

---------- File: gen_main.adb ----------
with ada.Text_io;

package body Gen_Main is

procedure Gen is
begin
    for count in 1 .. Number_of_times loop
        Ada.Text_Io.Put_Line( "Count = " & Integer'Image( count ) );
    end loop;
end Gen;

end Gen_Main;
----------------------------------------

I create an instance of the generic

---------- File: main.adb ----------
with gen_main;
procedure main is new gen_Main.Gen( 10 );
-----------------------------------

This program builds and runs under ObjectAda 7.2 as expected.
Using Gnat 3.14p, I get the error:

D:\>gnatmake -v Main

GNATMAKE 3.14p  (20010503) Copyright 1995-2001 Free Software Foundation,
Inc.
  "main.ali" being checked ...
  -> "main.ali" missing.
gcc -c main.adb
main.adb:2:11: warning: file name does not match unit name, should be
"main.ads"

main.adb:2:11: generic instantiation for "main" does not allow a body
main.adb:2:11: remove incorrect body in file "main.adb"
End of compilation
gnatmake: "main.adb" compilation error


Should this work?

SteveD






             reply	other threads:[~2002-11-09 17:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-09 17:54 SteveD [this message]
2002-11-09 19:10 ` Can the main procedure be a generic instance? sk
2002-11-09 20:17   ` SteveD
2002-11-09 20:39 ` David C. Hoos, Sr.
replies disabled

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