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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cf6d7cfa23391bce X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-11 07:57:54 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!skynet.be!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: ada_wizard@toadmail.com Newsgroups: comp.lang.ada Subject: Re: Problem with visibility of generic package help please Date: Thu, 11 Dec 2003 10:55:50 -0500 Organization: Cuivre, Argent, Or Message-ID: NNTP-Posting-Host: lovelace.ada-france.org X-Trace: melchior.cuivre.fr.eu.org 1071158157 50578 80.67.180.195 (11 Dec 2003 15:55:57 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Thu, 11 Dec 2003 15:55:57 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.3 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:3379 Date: 2003-12-11T10:55:50-05:00 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 "Ute" writes: > I'm trying to instantiate a generic package with doesn't become > visible in the main program. However, the specifiacation of the > package and the package body do separately compile without errors. I > am using GNAT. First, congratulations on learning Ada! it is a great language :) When I tried to compile your program (with GNAT 3.15p), I got many error messages. They are telling you what the problem is; you just need practice in reading them. gnatmake -k -O3 -gnatn -gnatwa -I.. generic_sort_demo Note that I have all warnings turned on (-gnatwa); this is very helpful. gcc -c -I./ -O3 -gnatn -gnatwa -I.. -I- ..\generic_sort_demo.adb generic_sort_demo.adb:5:09: warning: no entities of "float_text_io" are referenced generic_sort_demo.adb:7:09: warning: no entities of "integer_text_io" are referenced generic_sort_demo.adb:9:09: warning: no entities of "integer_text_io" are referenced These are hints that the "put" functions you want to use are not being used. generic_sort_demo.adb:17:60: no visible subprogram matches the specification for "put" In generic_sort.ads, you have a generic formal procedure parameter: with procedure put(X: Elem); However, the actual declaration of Put in Ada.Integer_Text_IO is: procedure Put (Item : in Num; Width : in Field := Default_Width; Base : in Number_Base := Default_Base); The Width and Base parameters have defaults, but that doesn't mean you can leave them out in generic formals. generic_sort_demo.adb:17:60: missing specification for "Width" and other formals with defaults Which is what this error message says :). GNAT has great error messages, but you do have to get in the right mind set to read them. So you need to add the missing parameters in the Put for generic_sort. Note that Ada.Float_Text_IO has different parameters; you cannot declare one generic formal procedure Put for both integer and float. generic_sort_demo.adb:17:65: no visible subprogram matches the specification for "get" generic_sort_demo.adb:17:65: missing specification for "Width" Same as above. generic_sort_demo.adb:19:08: "int_arr_sort" is undefined generic_sort_demo.adb:19:08: possible misspelling of "int_arrr_sort" This is clear, I hope; you typed 3 r's by mistake. GPS and Emacs will automatically correct this sort of error, at a single keystroke. generic_sort_demo.adb:21:09: "ArrTyp" is not visible generic_sort_demo.adb:21:09: non-visible declaration at generic_sort.ads:15 generic_sort_demo.adb:27:04: "get_array" is not visible generic_sort_demo.adb:27:04: non-visible declaration at generic_sort.ads:25 generic_sort_demo.adb:33:04: "put_array" is not visible (more references follow) generic_sort_demo.adb:33:04: non-visible declaration at generic_sort.ads:23 generic_sort_demo.adb:37:04: "sort" is not visible generic_sort_demo.adb:37:04: non-visible declaration at generic_sort.ads:21 These can be somewhat confusing. You are trying to use the subprograms defined by your generic; the problem is that the generic instantiation failed, so they are not visible. GNAT tries to be helpful and find other places where the same names are visible. In this case, it guessed wrong. I suggest you separate the "put" functionality from the "sort" functionality; put them in separate packages. That will help a lot. You should consider using SAL.Gen_Array_Text_IO (http://www.toadmail.com/~ada_wizard/) for the "put" part; it "just works", and supports integer and float arrays "out of the box", so you can just focus on the "sort" part. Even if this is homework, I would not call it cheating; having to do complex Text_IO in order to do the "real work" is just annoying. So take advantage of what's out there. -- -- Stephe ___________________________________________________________ This mail sent using ToadMail -- Web based e-mail @ ToadNet