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,f23882dec7858ff X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!m34g2000hsf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: What is the best way to define the Imported C function Date: Mon, 28 Jan 2008 09:18:17 -0800 (PST) Organization: http://groups.google.com Message-ID: <63f505fe-19fc-48e1-8c7c-f4bcb52c99df@m34g2000hsf.googlegroups.com> References: <5db8e5dd-9632-4aef-b1e3-8cc304bcd748@u10g2000prn.googlegroups.com> <6aRmj.3192$yE1.490@attbi_s21> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1201540698 1175 127.0.0.1 (28 Jan 2008 17:18:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 28 Jan 2008 17:18:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m34g2000hsf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19632 Date: 2008-01-28T09:18:17-08:00 List-Id: On Jan 26, 5:31 pm, "Jeffrey R. Carter" wrote: > I can't help you (and really, neither can those who have replied to you) because > the C specification isn't a specification; it doesn't tell us how the function > uses its parameters. Without that information, we can't tell how to interface to it. > > The problem is that C uses the same construct for many conceptually different > things. For example: > > void f (char* c); > > may represent something that is conceptually equivalent to Ada's > > procedure F (C : in Character); [unlikely, but possible] > procedure F (C : in out Character); > procedure F (C : out Character); > procedure F (C : in String); > procedure F (C : in out String); > procedure F (C : out String); > > Given the common practice of using "char" to represent what Ada calls a > Storage_Element, and "char[]" or "char*" for Storage_Array, this single C > declaration may mean any of 12 different things. It's probably worse than that, because even when char * refers to a structure with multiple characters rather than a single character, you don't know whether it's supposed to be a null-terminated string, or an array of characters whose size is given somewhere else, or what. -- Adam