* Deference question
@ 2003-02-26 15:34 Papandopulo
2003-02-26 19:06 ` Stephen Leake
2003-02-26 19:30 ` Martin Krischik
0 siblings, 2 replies; 3+ messages in thread
From: Papandopulo @ 2003-02-26 15:34 UTC (permalink / raw)
Maybe simple question, but I am just starting with Ada.
I try to read an array from file using streams:
declare
type X_Value is mod 2**8;
type X_Buffer is array (Positive range <>) of X_Value;
type X_Buffer_Access is access all X_Buffer;
type X_Buffer_Sz is new X_Buffer (1 .. Positive(Q_Bytes));
type X_Buffer_Sz_Access is access all X_Buffer_Sz;
Buff : X_Buffer_Sz_Access;
begin
Buff := new X_Buffer_Sz;
X_Buffer_Sz'Read (X_Stream, Buff'all);
end;
But gnat tells me:
attribute designator expected
on the dereference (Buff'all)
What's wrong ?
Thank you,
George
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Deference question
2003-02-26 15:34 Deference question Papandopulo
@ 2003-02-26 19:06 ` Stephen Leake
2003-02-26 19:30 ` Martin Krischik
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Leake @ 2003-02-26 19:06 UTC (permalink / raw)
papand0pul0@yahoo.com (Papandopulo) writes:
> Maybe simple question, but I am just starting with Ada.
>
> I try to read an array from file using streams:
>
> declare
> type X_Value is mod 2**8;
> type X_Buffer is array (Positive range <>) of X_Value;
> type X_Buffer_Access is access all X_Buffer;
> type X_Buffer_Sz is new X_Buffer (1 .. Positive(Q_Bytes));
> type X_Buffer_Sz_Access is access all X_Buffer_Sz;
> Buff : X_Buffer_Sz_Access;
> begin
> Buff := new X_Buffer_Sz;
> X_Buffer_Sz'Read (X_Stream, Buff'all);
> end;
>
> But gnat tells me:
> attribute designator expected
> on the dereference (Buff'all)
You want Buff.all, not Buff'all.
the ' means the following identifier is an "attribute", like 'Read.
But you want a dereference, which is .all
--
-- Stephe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Deference question
2003-02-26 15:34 Deference question Papandopulo
2003-02-26 19:06 ` Stephen Leake
@ 2003-02-26 19:30 ` Martin Krischik
1 sibling, 0 replies; 3+ messages in thread
From: Martin Krischik @ 2003-02-26 19:30 UTC (permalink / raw)
On Wed, 26 Feb 2003 07:34:03 +0000, Papandopulo wrote:
> Maybe simple question, but I am just starting with Ada.
>
> I try to read an array from file using streams:
>
> declare
> type X_Value is mod 2**8;
> type X_Buffer is array (Positive range <>) of X_Value;
> type X_Buffer_Access is access all X_Buffer;
> type X_Buffer_Sz is new X_Buffer (1 .. Positive(Q_Bytes));
> type X_Buffer_Sz_Access is access all X_Buffer_Sz;
> Buff : X_Buffer_Sz_Access;
> begin
> Buff := new X_Buffer_Sz;
> X_Buffer_Sz'Read (X_Stream, Buff'all);
Typo: it is .all but 'Access.
Ada does not need as many pointer. So unless there is a good reason
against it I would suggest:
Buff : X_Buffer_Sz;
begin
X_Buffer_Sz'Read (X_Stream, Buff);
> end;
>
> But gnat tells me:
> attribute designator expected
> on the dereference (Buff'all)
>
> What's wrong ?
With regards
Martin
--
Martin Krischik
mailto://Martin@krischik.com
http://www.ada.krischik.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-02-26 19:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-26 15:34 Deference question Papandopulo
2003-02-26 19:06 ` Stephen Leake
2003-02-26 19:30 ` Martin Krischik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox