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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,55a8252137b5ef97 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Vinzent 'Gadget' Hoefler Newsgroups: comp.lang.ada Subject: Re: Efficiently setting up large quantities of constant data Date: Fri, 17 Dec 2004 08:38:41 +0000 Message-ID: <25075763.yogBpGQTl0@jellix.jlfencey.com> References: <2508656.W3VlADmtU1@jellix.jlfencey.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net +vHPt2EM+Op6ICitqFnlGA7tOh+CgL/bUeYcHr8I4Eea3XUWD9 X-Phone: +41 62 961 13 52 Xref: g2news1.google.com comp.lang.ada:7020 Date: 2004-12-17T08:38:41+00:00 List-Id: tmoran@acm.org wrote: >>You could give "objcopy" a try. It can convert a binary file into an >>object file which could then be linked normally. > > You could also create an asm (remember that?) file with the data > and link the resultant object file. Yes. BTDT. > What's wrong with just creating an Ada source file with all the > constant data? It's nothing wrong with it. But sometimes it just may seem a little bit overkill to create source code from a binary to be compiled by a compiler to get an object file to be linked by the linker when you can create the needed object file in just one single, fast step with bin2obj/objcopy. :) > That would give you the advantage of the compiler doing the > worrying about the data representation and layout and doing some > checking that you are accessing things correctly. Yes, agreed. If you really need this. But if the file is essentially just an array of basic types I see not much sense in doing all the steps mentioned above just to link a lookup-table into the executable. I mean, what kind of checking can the compiler do on a simple array of integers? Especially in the case when the program that writes the binary data uses the same packages with the type declaration as the program where the precomputed result is linked into? Oh, and floating point data might be a little bit funny, if you convert the binary result to textual representation, and then let the compiler convert it back to its binary equivalent. ;-) Vinzent.