comp.lang.ada
 help / color / mirror / Atom feed
* How did dynamic elaboration fix cyclic elaboration error???
@ 2006-04-06 22:59 stuart clark
  2006-04-06 23:45 ` Robert A Duff
  2006-04-07  6:02 ` Simon Wright
  0 siblings, 2 replies; 3+ messages in thread
From: stuart clark @ 2006-04-06 22:59 UTC (permalink / raw)


I have some old UATL code i had compiled up into a library. When i
attempted to create an executable proram that used thelibrary i got a
bind error, "cyclic elaboration error".  The info on the error report
was;

1. uatl_stim_response_device_interface must be elaborated before
uatl_function_task

2. uatl_function_task must be elaborated before
uatl_stim_response_message_routing.

3. uatl_stim_response_message_routing must be elaborated before
uatl_stim_response_device_interface

that is

a. uatl_stim_response_device_interface with's
uatl_stim_response_message_routing

b. uatl_stim_response_message_routing with's utal_function_task

c.  utal_function_task with's uatl_stim_response_device_interface.

i had the appropriate pragma elaborates in the bodies for each of the
packages involed in the above errors, ie

uatl_stim_response_device_interface package body had pragam
elaborate(uatl_stim_response_message_routing).

We are using Gnat Pro here at work and one of the guys i'm working with
suggested turning on dynamic_elaboration in the UATL library, ie the
ada compile gnat switch -gnatE. Note I also took out the pragma
elaborates described above.

This worked !!! the bind error disappeared.

DOES ANYONE KNOW WHY???

Stuart Clark.




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

* Re: How did dynamic elaboration fix cyclic elaboration error???
  2006-04-06 22:59 How did dynamic elaboration fix cyclic elaboration error??? stuart clark
@ 2006-04-06 23:45 ` Robert A Duff
  2006-04-07  6:02 ` Simon Wright
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 2006-04-06 23:45 UTC (permalink / raw)


"stuart clark" <stuartlclark@hotmail.com> writes:

> We are using Gnat Pro here at work and one of the guys i'm working with
> suggested turning on dynamic_elaboration in the UATL library, ie the
> ada compile gnat switch -gnatE. Note I also took out the pragma
> elaborates described above.
> 
> This worked !!! the bind error disappeared.
> 
> DOES ANYONE KNOW WHY???

If you're using GNAT Pro, I guess you have a support contract with
AdaCore, and you can ask AdaCore.

Elaboration order problems (including cycles) can be very confusing and
frustrating.  You should read the section "Elaboration Order Handling in
GNAT" in the GNAT User's Guide.

By default, GNAT uses a static method, which being static, is of course
conservative.  The static method does not conform to the Ada standard --
some legal Ada programs will be rejected.  The -gnatE switch causes GNAT
to conform the Ada standard, which requires run-time checks.  This means
that the bind error will disappear, and you might or might not get
run-time errors during elaboration.

It is best to avoid -gnatE, if possible.

With -gnatE, if you get no run-time errors during elaboration, you're
OK for now (assuming you don't do anything weird during library-level
elaboration, such as conditional code based on input data).  But you
code might not be portable to a different compiler (such as a newer
version of GNAT that happens to choose a different order).

- Bob



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

* Re: How did dynamic elaboration fix cyclic elaboration error???
  2006-04-06 22:59 How did dynamic elaboration fix cyclic elaboration error??? stuart clark
  2006-04-06 23:45 ` Robert A Duff
@ 2006-04-07  6:02 ` Simon Wright
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Wright @ 2006-04-07  6:02 UTC (permalink / raw)


"stuart clark" <stuartlclark@hotmail.com> writes:

Bob Duff has answered this, a further point:

> a. uatl_stim_response_device_interface with's
> uatl_stim_response_message_routing
>
> b. uatl_stim_response_message_routing with's utal_function_task
>
> c.  utal_function_task with's uatl_stim_response_device_interface.

I suspect the problem may relate to a library-level task? GNAT doesn't
know what you may have done to ensure that the task never calls the
device_interface until elaboration is complete.

A solution is often to use a task _type_ and not create the task
_instance_ until elaboration is complete. I realise this may be
awkward, especially with legacy code.



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

end of thread, other threads:[~2006-04-07  6:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-06 22:59 How did dynamic elaboration fix cyclic elaboration error??? stuart clark
2006-04-06 23:45 ` Robert A Duff
2006-04-07  6:02 ` Simon Wright

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