Problem with generic parameter



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;
.



Relevant Pages

  • Re: Problem with generic parameter
    ... unlogical generic idiom, and probably the bug has passed unnoticed before for this reason. ... I would find it logical to represent the array type as an exported entity instead of a generic parameter. ... type Measurement is array of Measurement; ... package Generic_Root.Child_By_Marius is ...
    (comp.lang.ada)
  • Re: generic package, cant find an error
    ... test program the package was instantiated with float type. ... from the source code of my program which you can see below. ... While I compile arrays.ads and arrays.adb ...
    (comp.lang.ada)
  • Re: Low absorption SMD capacitors
    ... that I measured for other ceramic-material 0805 capacitors. ... Is ordinary FR4 PCB ... and I subtract this out by taking a dark measurement at the ... Another 'oddity' is that the SO8 package of this device (which I'm ...
    (sci.electronics.design)
  • Re: Problem with generic parameter
    ... type Indices is; package Generic_Root type Measurement is array of Measurement; ... new Generic_Root (Scalar => Scalar); ...
    (comp.lang.ada)
  • Re: AIO Support and related package information??
    ... package for arm platform,with bare Kernel AIO Support ... test program while cross compiling ... echo "$as_me: error: cannot run test program while ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)

Loading