comp.lang.ada
 help / color / mirror / Atom feed
From: rgilbert@orl.mmc.com (Bob Gilbert)
Subject: Problem with Address Clauses
Date: 9 Feb 1995 18:11:39 GMT
Date: 1995-02-09T18:11:39+00:00	[thread overview]
Message-ID: <3hdlsr$a8a@theopolis.orl.mmc.com> (raw)

I believe that I may have posted this problem to the group
some time ago, so I appologize if I'm being somewhat redundant
of if the question was answered earlier, but here goes:

I'm using an Ada '83 compiler that appears to require a "static
expression" for the address clause.  This is preventing me from
implementing generic packages which would provide an interface to
various memory mapped devices, where multiple instances of these
devices might exist for one processor and/or the device may be used 
on several different processors but at different base addresses.
I know that I can "work around" this by using access types and
unchecked conversion to resolve the mapping, but I feel that this
should not be necessary and goes against the spirit of the Ada
language (not portable, etc.). I've used this technique of writing 
generic interfaces to memory mapped devices with several other Ada 
compilers in the past with no problems, and it seems that this is 
an unreasonable limitation of this particular compiler.  Do I have
a valid gripe, or is the compiler vendor within the legal definition 
of the language?  Also, the vendor informs me that this problem will
still exist even with there Ada 95 offerings.  Should I continue
pressing the vendor on this point?

The following is a sample piece of code that highlights the problem:

   with System;
   package Address_Clause is

     type SYSTEM_TYPE is (Ax, Bx);
 
     type BASE_ADDR_ARRAY is array (SYSTEM_TYPE) of SYSTEM.ADDRESS;

     X_Base_Table : constant BASE_ADDR_ARRAY :=
                      BASE_ADDR_ARRAY'(Ax => 16#0020_0000#,
                                       Bx => 16#0010_0000#);

     ---------------------------------------------------------------
     -- Ultimately this package would be implemented as a generic  -
     -- where the array index (Ax) used to identify the system,    -
     -- would be supplied as a generic parameter.  The generic     -
     -- implementation is not shown to avoid unnecessary           -
     -- complications (this comment seems to provides sufficient   -
     -- confusion anyway).                                         -
     ---------------------------------------------------------------
     XBase   : constant SYSTEM.ADDRESS := X_Base_Table(Ax);
     XAddr_1 : constant SYSTEM.ADDRESS := XBase + 0;

     X1 : INTEGER;
       for X1 use at XAddr_1;

   end Address_Clause;


When I compile the above I get the following error:

   ____________________________________________________________________________

     23|  X1 : INTEGER;
     24|    for X1 use at XAddr_1;
                          ^1
   ***  1 Error 3271: A static expression is expected here (4.9) 
     25|
   ____________________________________________________________________________



Thanks in advance for any inputs and opinions,

-Bob




             reply	other threads:[~1995-02-09 18:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-02-09 18:11 Bob Gilbert [this message]
1995-02-10 15:16 ` Problem with Address Clauses Theodore E. Dennison
1995-02-11 13:57 ` Robert Dewar
     [not found]   ` <3hsvie$a2u@theopolis.orl.mmc.com>
     [not found]     ` <3hug0j$f50@felix.seas.gwu.edu>
     [not found]       ` <3hvlbd$pk6@theopolis.orl.mmc.com>
     [not found]         ` <3ibsta$2ub@felix.seas.gwu.edu>
     [not found]           ` <3idapr$ngb@watnews1.watson.ibm.com>
1995-02-25 21:19             ` ANSI C allows extensions (was: Problem with Address Clauses) Robert Dewar
replies disabled

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