* Representation Freezing Rules vs. Storage management
@ 2004-04-15 14:36 Reinhold May
2004-04-16 8:24 ` Lutz Donnerhacke
0 siblings, 1 reply; 2+ messages in thread
From: Reinhold May @ 2004-04-15 14:36 UTC (permalink / raw)
Hi,
I've got a problem with the following code:
i : integer;
for i'address use get_address(i'size, i'alignment);
I've compiled an example featuring this code using the Green
Hills Ada compiler without a problem.
Gnat fails returning:
representation item appears too late
Although it makes sense to me that this code compiles (because
after all knowing the size of a variable and its alignment is
required to find a proper address and thus is probably required
in any kind of storage management), after reading some
contributions to the newsgroup and the LRM 13.14 (Freezing
Rules), I can understand why Gnat doesn't allow me to do it.
So my first question is, is the above code legal Ada95 code?
If not, does anyone have an idea how I could get the same effect
using legal code?
I thought about using the type's attributes rather than the
variable's ones, like the following:
i : integer;
for i'address use get_address(integer'size, integer'alignment);
My problem is, I'm having to insert this type of representation
clause into an existing application (quite a large one).
The application has definitions like:
a : array(1 .. 10) of integer;
which couldn't be used in a representation clause shown above as
the type is defined implicitely rather than explicitely. So the
type would have to be defined explicitly on each occurrence.
The type of a variable is not always easy to find out and trying
that would require a full Ada parser (but of course that's
feasible).
A specific 'size respectively 'alignment clause would have to be
recognised and used instead of the type's attributes in order to
get the right address (but with the above mentioned parser this
would be feasible as well although costing a lot of effort).
Any pointer into the right direction is very welcome.
Thanks,
Reinhold
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Representation Freezing Rules vs. Storage management
2004-04-15 14:36 Representation Freezing Rules vs. Storage management Reinhold May
@ 2004-04-16 8:24 ` Lutz Donnerhacke
0 siblings, 0 replies; 2+ messages in thread
From: Lutz Donnerhacke @ 2004-04-16 8:24 UTC (permalink / raw)
* Reinhold May wrote:
> The application has definitions like:
>
> a : array(1 .. 10) of integer;
type A_Array is array(1 .. 10) of Integer;
a : A_Array;
for a'Address use get_address(A_Array'Size, A_Array'Alignment);
> the type is defined implicitely rather than explicitely. So the
> type would have to be defined explicitly on each occurrence.
Ack.
> The type of a variable is not always easy to find out and trying
> that would require a full Ada parser (but of course that's
> feasible).
You do not know what you type in?
> Any pointer into the right direction is very welcome.
Use dynamic allocation from a user defined pool.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-04-16 8:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-15 14:36 Representation Freezing Rules vs. Storage management Reinhold May
2004-04-16 8:24 ` Lutz Donnerhacke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox