Problem with generic parameter
- From: Jacob Sparre Andersen <sparre@xxxxxx>
- Date: 22 Jun 2005 12:21:10 +0200
When I try to compile the program included below (cut down version of
a test program) GNAT 3.15p reports:
-----
Compiling: demo.adb (source file time stamp: 2005-06-22 10:10:41)
16. Measurement_Array => Measurement_Array);
|
>>> component subtype of actual does not match that of formal "Measurement_Array"
>>> instantiation abandoned
20 lines: 2 errors
-----
I can't see _how_ it doesn't match. Can somebody figure out what I'm
doing wrong? And maybe even suggest me an elegant solution to the
problem?
The reason I have Measurement_Array as a generic parameter is that I
also use it elsewhere, and that I may want to work with differently
indexed measurement arrays. Does it - despite that - make more sense
to declare the types "Measurement" and "Measurement_Array" together?
/Jacob
------------------------------------------------------------------------------
-- Source code:
with Generic_Root;
with Generic_Root.Child;
procedure Demo is
type Scalar is digits 15;
package Measurements is
new Generic_Root (Scalar => Scalar);
type Measurement_Array is array (Positive range <>)
of Measurements.Measurement;
package Measurement_Text_IO is
new Measurements.Child (Indices => Positive,
Measurement_Array => Measurement_Array);
begin
null;
end Demo;
generic
type Scalar is digits <>;
package Generic_Root is
---------------------------------------------------------------------------
-- type Limit:
type Limit is (Below, Exact, Above, Undefined);
---------------------------------------------------------------------------
-- type Measurement:
type Measurement (As : Limit := Exact) is
record
case As is
when Below | Exact | Above =>
Value : Scalar;
when Undefined =>
null;
end case;
end record;
---------------------------------------------------------------------------
end Generic_Root;
with Ada.Text_IO;
generic
type Indices is (<>);
type Measurement_Array is array (Indices range <>) of Measurement;
package Generic_Root.Child is
end Generic_Root.Child;
.
- Follow-Ups:
- Re: Problem with generic parameter
- From: Marius Amado Alves
- Re: Problem with generic parameter
- From: Martin Dowie
- Re: Problem with generic parameter
- Prev by Date: Re: Interrupt handler seems not to be called in GNAT 3.15p
- Next by Date: Re: ADA Excel API
- Previous by thread: Re: AI302.Containers bug : solved
- Next by thread: Re: Problem with generic parameter
- Index(es):
Relevant Pages
|
Loading