comp.lang.ada
 help / color / mirror / Atom feed
* Can the main procedure be a generic instance?
@ 2002-11-09 17:54 SteveD
  2002-11-09 19:10 ` sk
  2002-11-09 20:39 ` David C. Hoos, Sr.
  0 siblings, 2 replies; 4+ messages in thread
From: SteveD @ 2002-11-09 17:54 UTC (permalink / 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






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-09 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-09 17:54 Can the main procedure be a generic instance? SteveD
2002-11-09 19:10 ` sk
2002-11-09 20:17   ` SteveD
2002-11-09 20:39 ` David C. Hoos, Sr.

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