comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Debugging Ada
Date: Wed, 21 Dec 2011 23:21:19 -0800 (PST)
Date: 2011-12-21T23:21:19-08:00	[thread overview]
Message-ID: <ca82c023-bfdb-42ac-a55c-4968f2b7b6cf@p16g2000yqd.googlegroups.com> (raw)
In-Reply-To: 87zkelvhbr.fsf@ludovic-brenta.org

On Dec 21, 11:46 am, Ludovic Brenta <ludo...@ludovic-brenta.org>
wrote:
> awdorrin <awdor...@gmail.com> writes:
> > Ah, I see what you are saying. I don't think that is what is going on
> > in this situation.
>
> > The code I'm working with is a mix of Ada and C, and it was originally
> > written under Ada83.
>
> > The 'SysConfig' package is importing a C character array:
> >   char g_cfg_file_names[100][128]; (up to 100 file names, 128
> > characters each)
> > as:
> >   pragma Import( C, CFG_FILES, "g_cfg_file_names");
>
> > LAN_CFG is part of an enumeration defined in the SysConfig package to
> > map to the index numbers of that array.
>
> OK, I think I understand the problem better too.  Your initial
> description of the problem was:
>
> > Then in the package's main procedure when I try to use the
> > LAN_CFG_FILE, sometimes the value is corrupted.
>
> I'm beginning to think that perhaps the elaboration order varies between
> compilations.  The pragma Import (C, CFG_FILES, "g_cfg_file_names")
> indicates that:
>
> - the Ada language rules require that g_cfg_file_names is elaborated
>   before LAN_CFG_FILE
> - the Ada compiler cannot enforce this rule, so it simply assumes that
>   the rule is followed
> - the C compiler must emit code that elaborates *and* initializes
>   g_cfg_file_names.  It is possible that what you see as "corrupted" is
>   simply an uninitialized value.
> - the binder must emit code that calls the C initialization routine
>   *before* the elaboration of LAN_CFG_FILE

If LAN_CFG_FILE is declared inside a procedure as shown in a previous
post, how can elaboration order be an issue?

                               -- Adam



  reply	other threads:[~2011-12-22  7:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 15:14 Debugging Ada awdorrin
2011-12-21 16:45 ` Ludovic Brenta
2011-12-21 16:51   ` awdorrin
2011-12-21 17:18     ` Ludovic Brenta
2011-12-21 17:36       ` awdorrin
2011-12-21 18:06         ` Simon Wright
2011-12-21 18:43           ` awdorrin
2011-12-21 19:46         ` Ludovic Brenta
2011-12-22  7:21           ` Adam Beneschan [this message]
2011-12-22  8:39             ` Ludovic Brenta
2011-12-22 12:20             ` awdorrin
2011-12-22 10:28 ` Gautier write-only
replies disabled

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