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,23ca868289d9f0c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: generic package with procedure paramter gives "not subtype conformant with declaration" References: <1159651201.121690.130430@b28g2000cwb.googlegroups.com> <1159682538.644835.248030@m7g2000cwm.googlegroups.com> In-Reply-To: <1159682538.644835.248030@m7g2000cwm.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <3UUTg.1003037$084.701942@attbi_s22> NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1159731839 12.201.97.213 (Sun, 01 Oct 2006 19:43:59 GMT) NNTP-Posting-Date: Sun, 01 Oct 2006 19:43:59 GMT Date: Sun, 01 Oct 2006 19:43:59 GMT Xref: g2news2.google.com comp.lang.ada:6826 Date: 2006-10-01T19:43:59+00:00 List-Id: cl1 wrote: > > I understand the reason for using access types with convention C, but > that > will not work for this situation. Everywhere i have used System.Address > the code > does not know, does not care what type or subprogram signature is > stored there, and will > not use it other than to pass it along to some c function that knows > what to do with it. If > there is a System.Address being used that doesn't fit that, then it is > a bug. I also choose > not to use 'type void_ptr is new System.Address;' specifically becuase > that is what > System.Address is. Also someone once told me that writing code that > requires the user > to with System; alerts the user that the code is system dependant. I > like that idea. This > code is system dependant. By that, I mean it is dependant on the > processor and in > some situations the operating system, not the compiler implementation. > Well to be > honest the Ada code isn't but the C code it interfaces with is > (ffcall's avcall). The problem is that System.Address is not guaranteed to be the same as a C pointer, so using it to interface with C makes your code compiler dependent. In all versions of GNAT that I've used and bothered to check, System.Address has been the same as a C pointer, but that could change at any time. For types, any convention-C access type will work for a void pointer when the values come from C and are never dereferenced by the Ada. I generally use "access all Integer" for that case, though some people prefer to have a void type to designate: type Void is null record; type Void_Ptr is access all Void; pragma Convention (C, Void_Ptr); Since values of Void_Ptr are never dereferenced, the designated type doesn't matter. For subprograms, it's more complicated because you have to match the subprogram parameter and return type profile. In your case, though (IIRC), the subprograms all have the same profile (that of your generic formal subprogram), so the use of a convention-C access type seems to be possible. > i'm using GPS which has gcc version 3.4.6 on mac os x 10.4.8 GPS is an IDE, not a compiler, but gcc 3.4.6 is; it's an Ada-95 compiler. The compiler version is of interest because Ada 95's accessibility rules differ from Ada 0X's. > I agree with you. > However, I am confused about this. The procedure could be declared > anywhere. How > does the compiler know what scope the procedure that is supplied to the > generic package is in? I mean can it ever know? If not, that means > there > is no foreseeable fix to this issue from my point of view. The compiler can't know the scope of the actual procedure in general; that's why you can never store the 'access of a generic formal procedure. The language assumes the worst case for safety. -- Jeff Carter "Monsieur Arthur King, who has the brain of a duck, you know." Monty Python & the Holy Grail 09