From: Martin Dowie <martin.dowie@btopenworld.com>
Subject: Re: Ada 2005 core packages under GNAT-GPL-2007
Date: 14 May 2007 13:20:42 -0700
Date: 2007-05-14T13:20:42-07:00 [thread overview]
Message-ID: <1179174042.304958.299200@p77g2000hsh.googlegroups.com> (raw)
In-Reply-To: <1179165457.315362.25970@e65g2000hsc.googlegroups.com>
On 14 May, 18:57, Anh Vo <anhvofrc...@gmail.com> wrote:
> Ada.Assertions package (AI-286 implemented by Martin Dowie) is part of
> Ada 2005 core packages as indicated by 14.4.2(12/2). However, when
> compiling codes having "with Ada.Assertions" in the with clause, GNAT
> displays ..."Ada.Assertions" is not a predefined library unit. GNAT
> does not seem to recognize it. Should a bug report be in order?
GNAT GPL 2007 doesn't include an implementation of this package but
you can add one yourself.
The original one on my web page was provided to allow Ada95 compilers
to provide something as close as possible to Ada2005 as possible. For
instance, Ada.Assertions could not be "Pure" as it had to rely on
Ada.Exceptions for the implementation.
This isn't true now we have an Ada2005 compiler! So here's a version
you can compile up yourself. Again once compiled you can move the
source/.ali/.o files into the appropriate locations. You may wish to
change the compilation options too. NB: the file a-assert.adb needs to
suppress the GNAT RM-style checks.
File a-assert.ads
-- (c) 2007 Martin Dowie
pragma License (Unrestricted);
package Ada.Assertions is
pragma Pure (Ada.Assertions);
Assertion_Error : exception;
procedure Assert (Check : in Boolean);
procedure Assert (Check : in Boolean;
Message : in String);
end Ada.Assertions;
File a-assert.adb
-- (c) 2007 Martin Dowie
package body Ada.Assertions is
procedure Assert (Check : in Boolean) is
begin
if not Check then
raise Assertion_Error;
end if;
end Assert;
procedure Assert (Check : in Boolean;
Message : in String) is
begin
if not Check then
raise Assertion_Error with Message;
end if;
end Assert;
end Ada.Assertions;
GPS project file (test_assertion.gpr):
project Test_Assertion is
for Object_Dir use "lib";
for Source_Dirs use ("src");
for Main use ("test_assertion.adb");
package Linker is
for Default_Switches ("ada") use ("-g");
end Linker;
package Binder is
for Default_Switches ("ada") use ("-E");
end Binder;
package Compiler is
for Default_Switches ("ada") use ("-gnato", "-fstack-check", "-
gnatE", "-g", "-gnata", "-gnat05");
for Switches ("a-assert.adb") use ("-gnato", "-fstack-check", "-
gnatE", "-g", "-gnata", "-gnat05", "-gnatyN");
end Compiler;
package Builder is
for Default_Switches ("ada") use ("-s", "-g", "-a", "-x");
end Builder;
end Test_Assertion;
File test_assertion.adb
with Ada.Assertions;
procedure Test_Assertion is
begin
Ada.Assertions.Assert (True);
Ada.Assertions.Assert (False);
end Test_Assertion;
The folder structure used was:
C:\Ada\test_assertion - test_assertion.gpr
C:\Ada\test_assertion\src - a-assert.ads a-assert.adb
test_assertion.adb
C:\Ada\test_assertion\lib - build files
Cheers
-- Martin
next prev parent reply other threads:[~2007-05-14 20:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-14 17:57 Ada 2005 core packages under GNAT-GPL-2007 Anh Vo
2007-05-14 20:14 ` Ludovic Brenta
2007-05-14 20:20 ` Martin Dowie [this message]
2007-05-14 21:11 ` Anh Vo
2007-05-16 3:00 ` Randy Brukardt
2007-05-22 14:41 ` Anh Vo
2007-05-22 14:50 ` Anh Vo
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox