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,9b05d372d1b25f25,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!l64g2000hse.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Interfacing to C and types visible to Ada Date: Thu, 3 Jul 2008 05:32:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 128.141.45.223 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1215088347 835 127.0.0.1 (3 Jul 2008 12:32:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 3 Jul 2008 12:32:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l64g2000hse.googlegroups.com; posting-host=128.141.45.223; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:990 Date: 2008-07-03T05:32:26-07:00 List-Id: I have a question related to interfacing to C, but I think it deserves a new thread. Imagine a C API that uses the int type to express something that does not have any dedicated domain. In other words, it is not "number of apples", not "height in meters", not "hotel room number", etc., it is just plain "integer", which meaning can depend on how the given library is actually used. We can use Interfaces.C.int for binding Ada to C, but there is still a need to expose somehow the type to regular Ada code. What type should be used? Standard.Integer is the most natural choice, because it clearly expresses the "domainless" character of the given type. On the other hand, it might not be the same as Interfaces.C.int in terms of its range. Interfaces.C.int might be a good choice as well, because it "guarantees" (modulo what we have discussed in another thread) that the information is transported correctly. The disadvantage is that it is ugly and exposes implementation details which are not needed. The Ada wrapper library might also define its own type that will be equivalent in range to Interfaces.C.int. What is the right name for such a type? "Integer" is the best choice due to the character of this type, but it collides with Standard.Integer. On the other hand, packages are supposed to be the cure for such conflicts. What do you recommend? I would go for the last option: "Integer" defined in the library's package. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com