comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <condicma@bogon.pwfl.com>
Subject: Re: Storage space question
Date: 1998/12/10
Date: 1998-12-10T00:00:00+00:00	[thread overview]
Message-ID: <366FE278.FAF73497@pwfl.com> (raw)
In-Reply-To: 9v6hGdgMLuwN-pn2-v5sq1RxFJ1z1@dt182n2f.tampabay.rr.com

Craig Allen wrote:
> 
> Hello!
> 
> the short version of my question is this:  If I'm using enumerations
> to
> define names that will represent specific bit patterns that my program
> may
> wish to use, do *all* these bit patterns allocate space? e.g.  with
> this:
> 
>    type DCD_Mode_Type is
>       (CARRIER_DETECT, SYNC_DETECT, LOW, HIGH);
>    for DCD_Mode_Type'Size use 2;
>    for DCD_Mode_Type use
>       (CARRIER_DETECT => 2#00#,
>        SYNC_DETECT    => 2#01#,
>        LOW            => 2#10#,
>        HIGH           => 2#11#
>        );
> 
> is space allocated for each of these definitions?  I ask because I
> added
> many of these types to a package I'm writing, and my memory map seems
> to
> have grown even without using these types yet.
> I'd like to have these names available for use, but taking no more
> space
> than what is necessary (like #define in C...) (I would only be using 1
> definition per application, no need for space declared for all
> definitions...)
> 
> I'm using Ada 83, but I don't think that matters.
> 
> Thanks.
> -Craig

This is going to be a compiler dependent question, so maybe you need to
post which compiler you are using.

In general, a type does not require any space. Only when you declare
objects of the type is memory allocated. However, the rules of Ada
require that certain information be available at run time concerning a
type, which means the compiler has to keep that information somewhere -
hence memory utilization. Remember that for a given enumeration type T,
Ada has a function T'Image which has to return the character string
associated with the given value (id est, "CARRIER_DETECT",
"SYNC_DETECT", etc.) I don't think that the representation clauses would
have any impact on storage, but maybe one of the compiler-writers in the
crowd can fill us in.

If you've got a good avionics-quality, embedded target, Ada compiler,
I'd expect it to have switches/options to disable some of this storage
allocation. In most compilers of this sort, if you promise not to ask
certain kinds of questions the compiler will agree to make
smaller/faster code, so look into the implementation defined pragmas and
compiler options.

MDC
-- 
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
Ph: 561.796.8997         Fx: 561.796.4669
***To reply, remove "bogon" from the domain name.***

"Transported to a surreal landscape, a young girl kills the first woman
she meets and then teams up with three complete strangers to kill
again."

        -- TV listing for the Wizard of Oz




  parent reply	other threads:[~1998-12-10  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-10  0:00 Storage space question Craig Allen
1998-12-10  0:00 ` dennison
1998-12-10  0:00 ` Marin David Condic [this message]
1998-12-10  0:00   ` Tucker Taft
1998-12-10  0:00     ` callen
1998-12-10  0:00       ` Marin David Condic
1998-12-10  0:00         ` Tucker Taft
1998-12-11  0:00           ` dennison
1998-12-11  0:00         ` Matthew Heaney
1998-12-11  0:00           ` Marin David Condic
1998-12-12  0:00             ` Matthew Heaney
1998-12-12  0:00               ` David C. Hoos, Sr.
1998-12-12  0:00                 ` Matthew Heaney
1998-12-14  0:00                 ` dennison
1998-12-10  0:00       ` dennison
1998-12-11  0:00       ` Matthew Heaney
1998-12-10  0:00   ` Pat Rogers
1998-12-10  0:00     ` dennison
1998-12-10  0:00       ` Pat Rogers
1998-12-10  0:00   ` Matthew Heaney
1998-12-10  0:00     ` dennison
replies disabled

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