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: "Marc A. Criley" Newsgroups: comp.lang.ada Subject: Re: Efficiently setting up large quantities of constant data Date: Thu, 16 Dec 2004 07:50:48 -0600 Message-ID: <32di5rF3lj4ggU1@individual.net> References: X-Trace: individual.net rQFXkq122wUWLfVLjN+GHwnpCrifkmQ9ZfWssyne58mLL5+fee X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Xref: g2news1.google.com comp.lang.ada:6993 Date: 2004-12-16T07:50:48-06:00 List-Id: "Dr. Adrian Wrigley" wrote: > A similar question I have is how to link in regular files and access > their contents in Ada. > > For example, suppose I have a binary file "distances.dat" containing > the (road) distances between 1000 different cities. This could be a 2MB > file computed by another application. How can I build a single executable > file containing the data and access it from the Ada code? > > I presume this needs to be done at the linker stage, but I don't > see any options to link in non-object files. The obvious alternative > of distributing the data files separately and reading them in > is slower and much less tidy than having a single self-contained binary. I don't know the answer to your real question about linking in such files, but the way we dealt with this problem _many_ years ago with some very large tables of math constants was to write a little tool that read in the file and then generated Ada source code that initialized a suitably defined data structure with the constants. (And I don't think we used big aggregates, because they were...well...too big. I think we had the tool generate thousands of assignment statements.) The generated file was quite large and took awhile to compile (it was 1985 after all :-), but it worked just fine for us. Of course it was a one-shot effort as well, since math constants don't change very often, so YMMV if you're dealing with changing data. Marc A. Criley McKae Technologies www.mckae.com