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,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ac6f6c30c45f808a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Duncan Sands Newsgroups: comp.lang.ada Subject: Re: Ada equivalent for C-pointer? Date: Fri, 14 Jan 2005 18:00:05 +0100 Organization: Cuivre, Argent, Or Message-ID: References: <41E7F653.2F899F47@alfred-hilscher.de> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1105722024 80712 212.85.156.195 (14 Jan 2005 17:00:24 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Fri, 14 Jan 2005 17:00:24 +0000 (UTC) Cc: Alfred Hilscher To: comp.lang.ada@ada-france.org Return-Path: User-Agent: KMail/1.7.1 In-Reply-To: <41E7F653.2F899F47@alfred-hilscher.de> Content-Disposition: inline X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:7775 Date: 2005-01-14T18:00:05+01:00 Hi Alfred, > I want to interface to a C-function expecting a "far *", what have I to > pass: an "access all ..." or "System.Address"? Are there differences > between access and address, or are their internal representations equal? > I use GNAT 3.15p. a System.Address is what you would expect a pointer to be: a (eg) 32 bit number referring to a memory address, like a C pointer. Most access types will be the same size as, and equivalent to, a System.Address, but some access types may be bigger ("fat pointers") because they contain some information about what they are pointing to. This is typical of access to unconstrained array types for example, where the access type usually holds a memory address and also the array bounds. What you should do is create an access type with convention C: type C_Pointer is access ... pragma Convention (C, C_Pointer); Here ... is whatever it is your pointer is pointing to, or anything (eg: Integer) if you are not actually going to dereference the pointer in your Ada program. The pragma makes sure that the access type is what a C program expects, basically a System.Address. Ciao, Duncan.