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 X-Received: by 2002:a05:6214:12cf:: with SMTP id s15mr590754qvv.241.1584440115241; Tue, 17 Mar 2020 03:15:15 -0700 (PDT) X-Received: by 2002:a9d:6c0b:: with SMTP id f11mr2912826otq.182.1584440114948; Tue, 17 Mar 2020 03:15:14 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 17 Mar 2020 03:15:14 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=192.107.155.10; posting-account=XfA3zgkAAABoz6fRf3Tehtnqqr7Ycml- NNTP-Posting-Host: 192.107.155.10 References: <6bcc6133-8c8b-4252-a8e6-fd64a5eec2ca@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Good/best way to enforce library-level instantiation a generic package From: Vincent Marciante Injection-Date: Tue, 17 Mar 2020 10:15:15 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:58205 Date: 2020-03-17T03:15:14-07:00 List-Id: On Tuesday, March 17, 2020 at 2:29:58 AM UTC-4, briot....@gmail.com wrote: > On Monday, March 16, 2020 at 7:51:29 PM UTC+1, Vincent Marciante wrote: > > I made a generic package that I want only to be instantiated at library level. > > I'm working on compile-time a way to enforce that desire which involves access > > type accessibility level checking but have not yet set it up correctly. > > Is there a better/standard way? > > The way I do this is using gnat-specific pragmas and attributes: > > generic > package Generics is > pragma Compile_Time_Error > (not Generics'Library_Level, "must be at library level"); > ... > end Generics; 'Library_Level is nice and clean! It should be part of the Standard! I am using GNAT but still have to be compatible with other compiler so will have to go with something along the lines of Randy's suggestion. Thanks.