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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!postnews.google.com!i3g2000cwc.googlegroups.com!not-for-mail From: "cl1" Newsgroups: comp.lang.ada Subject: Re: generic package with procedure paramter gives "not subtype conformant with declaration" Date: 3 Oct 2006 11:49:00 -0700 Organization: http://groups.google.com Message-ID: <1159901339.997041.315860@i3g2000cwc.googlegroups.com> References: <1159651201.121690.130430@b28g2000cwb.googlegroups.com> <1159682538.644835.248030@m7g2000cwm.googlegroups.com> <3UUTg.1003037$084.701942@attbi_s22> <1159738009.962575.108920@i42g2000cwa.googlegroups.com> <1159763506.841048.175930@m73g2000cwd.googlegroups.com> NNTP-Posting-Host: 66.160.210.89 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1159901345 5015 127.0.0.1 (3 Oct 2006 18:49:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 3 Oct 2006 18:49:05 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i3g2000cwc.googlegroups.com; posting-host=66.160.210.89; posting-account=MCxsfw0AAABxs2rB6FOIOk-6XLUrvbBM Xref: g2news2.google.com comp.lang.ada:6849 Date: 2006-10-03T11:49:00-07:00 List-Id: Jeffrey R. Carter wrote: > cl1 wrote: > > > > Genius, pure genius! :D > > Thanks. More accurately, experience and a desire to be portable whenever > possible. > > > For anyone who is curious. This crazy code is being implemented so that > > you can call variable argument c functions. It interfaces with ffcall's > > avcall which is like, as they describe, av_list in reverse. So far I > > have the code that autogenerates wrappers for the avcall macros. The > > code I orginally posted is the code to store all the parameters to the > > variable argument C function. The process for a user of my packages > > should be: > > I guess you have to handle any number of arguments. For specific or > commonly used cases, you can declare multiple Ada subprograms, each with > different numbers or types of parameters, that all pragma Import the > same C function. Since you're generating packages for your clients, > perhaps it would be easier on your clients if you generated such > specific subprograms for them. > > For example: > > package C renames Interfaces.C; > > procedure Print_Str (Format : in C.Char_Array; Str : in C.Char_Array); > pragma Import (C, Print_Str, "printf"); > > procedure Print_Int (Format : in C.Char_Array; Num : in C.Int); > pragma Import (C, Print_Int, "printf"); > > procedure Print_Str_Int (Format : in C.Char_Array; > Str : in C.Char_Array; > Num : in C.Int); > pragma Import (C, Print_Str_Int, "printf"); > > -- > Jeff Carter > "It's all right, Taggart. Just a man and a horse being hung out there." > Blazing Saddles > 34 If my information serves me correctly, Ada doesn't define what happens when you import variable argument functions like that. It recomends that the only sure way is to write a c function wrapper that calls the variable argument function. The cool thing about ffcall's avcall is that I only have to write 2 wrapper functions for each type. One for the case where it is a return value, and one where it is an argument to the function. That is what my autogeneration code does. It writes those wrapper functions, and the coresponding ada procedures and their pramga import.