comp.lang.ada
 help / color / mirror / Atom feed
* premature usage of incomplete private type
@ 2001-11-07 23:00 Robert Jäschke
  2001-11-08 17:55 ` Reivilo Snuved
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Jäschke @ 2001-11-07 23:00 UTC (permalink / raw)



Hello!

I'm writing a package for Rational-Arithmetics and there I've got a problem.
I want to declare a constant of type Rational before the type itself is
proper defined and I don't know how I can go around this problem:


package My_Math.Rational is

      type Rational is private;

      Zero : constant Rational := (Z => 0, N => 1);

      --  some declarations ...

private

      type Rational is record
            Z : Integer;  --  Z�hler
            N : Integer;  --  Nenner
      end record;

end My_Math.Rational;


If I try to compile this specification, GNAT gives me this error:

gnatgcc -c -gnatg my_math-rational.ads
my_math-rational.ads:10:07: premature usage of incomplete private type
"Rational" defined at line 8
my_math-rational.ads:10:35: expected private type "Rational" defined at line
8
my_math-rational.ads:10:35: found a composite type
gnatmake: "my_math-rational.ads" compilation error


How can I solve this problem without making Rational non-private? Is there
any way, to say the compiler, that this type will be defined later?

Thanks for your help, 

Robert



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

* Re: premature usage of incomplete private type
  2001-11-08 17:55 ` Reivilo Snuved
@ 2001-11-07 23:00   ` Robert Jäschke
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Jäschke @ 2001-11-07 23:00 UTC (permalink / raw)


Reivilo Snuved <odevuns@iname.JUNK.com> wrote: 

> > I'm writing a package for Rational-Arithmetics and there I've got a problem.
> > I want to declare a constant of type Rational before the type itself is
> > proper defined and I don't know how I can go around this problem:
> [snip]
> Try this : 
[snip]

Thanks, that makes some things much clearer!

Robert






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

* Re: premature usage of incomplete private type
  2001-11-07 23:00 premature usage of incomplete private type Robert Jäschke
@ 2001-11-08 17:55 ` Reivilo Snuved
  2001-11-07 23:00   ` Robert Jäschke
  0 siblings, 1 reply; 3+ messages in thread
From: Reivilo Snuved @ 2001-11-08 17:55 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]

robert-j@gmx.de (Robert =?iso-8859-1?Q?J=E4schke?=) writes:

> Hello!
> 
> I'm writing a package for Rational-Arithmetics and there I've got a problem.
> I want to declare a constant of type Rational before the type itself is
> proper defined and I don't know how I can go around this problem:
[snip]

Try this : 

 package My_Math.Rational is
    type Rational is private;
    Zero : constant Rational;
 private
    type Rational is
       record
           Z : Integer;  --  Z�hler
           N : Integer;  --  Nenner
       end record;
    Zero : constant Rational := (Z => 0, N => 1);
 end My_Math.Rational;



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

end of thread, other threads:[~2001-11-08 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-07 23:00 premature usage of incomplete private type Robert Jäschke
2001-11-08 17:55 ` Reivilo Snuved
2001-11-07 23:00   ` Robert Jäschke

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