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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How to include shared code Date: Thu, 19 Sep 2013 07:24:55 +0100 Organization: A noiseless patient Spider Message-ID: References: <87zjr9u0ja.fsf@nl106-137-194.student.uu.se> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="7dbada740c46569bcf2d071123d9d707"; logging-data="27411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/q/ID4B5A+M09IHsGd3OcWY+gdsp+bRU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:SDSyPtxpgbi2kslLvxsovJAkWic= sha1:07CTEz2WMaSVj1QDhyAIskdTNsA= Xref: number.nntp.dca.giganews.com comp.lang.ada:183381 Date: 2013-09-19T07:24:55+01:00 List-Id: Peter Brooks writes: > On Thursday, 19 September 2013 02:17:52 UTC+2, Emanuel Berg wrote: >> >> Now, how can I extract that piece of code from both files, and put >> it into another file, say, random_period.adb, and then "include" >> it into each of the above files (that operate in isolation)? >> > That's what .ads files are for - you specify your function (and > everything else you need shared) in a package in a .ads file. Then the > gnat make will find and incorporate it: > > http://blog.projectpolymath.org/ada-2012-tutorial_01/ > > gives an example of what a .ads file looks like at the bottom. The relevant chapter in "Ada 95: The Craft of Object-Oriented Programming" is http://archive.adaic.com/docs/craft/html/ch04.htm#4.7 (NB, external references in this document won't work)