comp.lang.ada
 help / color / mirror / Atom feed
From: "snoopysalive@googlemail.com" <snoopysalive@googlemail.com>
Subject: Re: How to extend packages
Date: Sat, 7 Jun 2008 14:50:07 -0700 (PDT)
Date: 2008-06-07T14:50:07-07:00	[thread overview]
Message-ID: <8d5d38c0-8a7a-4e74-8e4f-da3276864ad7@z66g2000hsc.googlegroups.com> (raw)
In-Reply-To: m2skvp5iza.fsf@mac.com

Ok, I've tried out Sébastien Morand's solution but it's still not
working. To be honest, it's possible that I'm just using the compiler
in a wrong way.

Here's my code:

------------------
-- s-regext.ads --
------------------

with System.Regpat;

package System.Regpat.Extended is
end System.Regpat.Extended;

------------------
-- s-regext.adb --
------------------

pragma No_Body;

-------------
-- rex.adb --
-------------

with System.Regpat.Extended;

procedure Rex is
begin
   null;
end Rex;



When compiling I get this messages:

$ gnatmake rex.adb
gnatbind -x rex.ali
error: "s-regext.ali" not found, "s-regext.ads" must be compiled
gnatmake: *** bind failed.


So, I try to comile s-regext.ads first and get this message:

$ gnatmake s-regext.ads
gnatmake: not allowed to compile "s-regext.ads"; use -a switch, or
compile file with "-gnatg" switch


When trying the -a switch:

$ gnatmake -a s-regext.ads
gcc -gnatpg -c s-regext.ads
s-regext.ads:1:12: warning: no entities of "Regpat" are referenced
gnatmake: "s-regext.ads" compilation error


When trying the -gnatg switch:

$ gnatmake -gnatg s-regext.ads
gnatmake: not allowed to compile "s-regext.ads"; use -a switch, or
compile file with "-gnatg" switch


I don't really understand what's happening here because when
simulating this kind of "inheritance" with packages written by myself,
it is working. Here's the example code:

--------------
-- test.ads --
--------------

with Ada.Text_IO;

package Test is

	procedure Say_Hello;

end Test;


--------------
-- test.adb --
--------------

package body Test is

	procedure Say_Hello is
	begin
		Ada.Text_IO.Put_Line ("Say_Hello");
	end Say_Hello;

end Test;


------------------
-- test-run.ads --
------------------

with Test;

package Test.Run is

	procedure Say_Something;

end Test.Run;


------------------
-- test-run.adb --
------------------

package body Test.Run is
	use Test;

	procedure Say_Something is
	begin
		Ada.Text_IO.Put_Line ("Say_Something");
	end Say_Something;

end Test.Run;


--------------
-- main.adb --
--------------

with Test.Run;

procedure Main is
begin
	Test.Say_Hello;
	Test.Run.Say_Something;
end Main;



$ gnatmake main.adb
gcc -c main.adb
gnatbind -x main.ali
gnatlink main.ali

$ ./main
Say_Hello
Say_Something


So, it seems as if it's not possible to extend packages of the
standard library. Or am I interpreting this in a wrong way?

Last but not least: Thanks for all your answers to my question.

Thanks,
Matthias



  reply	other threads:[~2008-06-07 21:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06 17:00 How to extend packages snoopysalive
2008-06-06 17:24 ` witmer
2008-06-06 17:45 ` Sébastien Morand
2008-06-07 14:21   ` Stephen Leake
2008-06-07 16:04   ` Simon Wright
2008-06-07 21:50     ` snoopysalive [this message]
2008-06-08 11:09       ` Simon Wright
2008-06-09 22:38         ` snoopysalive
2008-06-10  5:40           ` Simon Wright
2008-06-14  8:45             ` snoopysalive
2008-06-06 18:16 ` Georg Bauhaus
replies disabled

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