From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.1 required=5.0 tests=BAYES_20,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ca15935e4fb21334 X-Google-Attributes: gid103376,public From: Marin David Condic Subject: Re: Storage space question Date: 1998/12/10 Message-ID: <366FE278.FAF73497@pwfl.com>#1/1 X-Deja-AN: 420821308 Content-Transfer-Encoding: 7bit Sender: condicma@bogon.pwfl.com References: <9v6hGdgMLuwN-pn2-v5sq1RxFJ1z1@dt182n2f.tampabay.rr.com> Content-Type: text/plain; charset=us-ascii Organization: Pratt & Whitney Mime-Version: 1.0 Reply-To: diespammer@pwfl.com Newsgroups: comp.lang.ada Date: 1998-12-10T00:00:00+00:00 List-Id: 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