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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Q: Localizing type and package references Date: Mon, 06 Jan 2014 08:05:06 +0000 Organization: A noiseless patient Spider Message-ID: References: <7d03f160-7f52-4870-b4b3-a03d5b351bcb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="d246eacd0950c31d9d52ec510be1b140"; logging-data="6121"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XwDzIslAM7G8eLsSlwQEPhO6Umz+W1Og=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:EH8v0twNW9W19t6zsuB/jspRQFM= sha1:F3+WqVZ3jj3kKxlCia8MhhVZyn0= Xref: news.eternal-september.org comp.lang.ada:18130 Date: 2014-01-06T08:05:06+00:00 List-Id: Jeffrey Carter writes: > On 01/05/2014 04:55 PM, b.mcguinness747@gmail.com wrote: >> >> -------------------------------------------------------------------------------- >> -- Types - Declarations of data types and related packages >> -------------------------------------------------------------------------------- >> with Ada.Characters; >> with Ada.Characters.Wide_Latin_1; >> with Ada.Strings; >> with Ada.Strings.Wide_Maps; >> with Ada.Strings.Wide_Unbounded; >> with Ada.Wide_Characters; >> with Ada.Wide_Characters.Handling; >> with Ada.Wide_Text_IO; >> with Ada.Wide_Text_IO.Text_Streams; >> >> package Types is >> package Chars renames Ada.Characters.Wide_Latin_1; >> package Char_Handling renames Ada.Wide_Characters.Handling; >> package Char_IO renames Ada.Wide_Text_IO; >> package Char_Maps renames Ada.Strings.Wide_Maps; >> package Char_Streams renames Ada.Wide_Text_IO.Text_Streams; >> package Char_Strings renames Ada.Strings.Wide_Unbounded; >> >> subtype Char is Wide_Character; >> subtype Char_String is Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; >> end Types; >> >> and then tried referencing this from the main program file with: >> >> with Types; >> use Types; >> >> with Char_Strings; >> >> but the compiler (Gnat 4.6) complains that there is no file called >> char_strings.ads. I am not sure if I have made a simple mistake that >> can be easily corrected to make this work, or if there is a different >> approach that I should be trying. > > You can only with a library-level package, one not declared in > anything else. Char_Strings is declared in package types, so it's not > library level and can't be withed. So, you can either reclare package Chars etc at library level: for example, in char_strings.ads, with Ada.Strings.Wide_Unbounded; package Char_Strings renames Ada.Strings.Wide_Unbounded; or you can change your main program file to say with Types; use Types; use Types.Chars; use Types.Char_Handling; ... or perhaps with Types; use Types; procedure Main is use Chars; use Char_Handling; ...