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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,610e53a911ec64b3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-24 09:30:09 PST Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!news.uni-stuttgart.de!rz.uni-karlsruhe.de!xlink.net!howland.reston.ans.net!gatech!news-feed-1.peachnet.edu!news.duke.edu!zombie.ncsc.mil!admii!cmcl2!thecourier.cims.nyu.edu!thecourier.cims.nyu.edu!nobody From: dewar@cs.nyu.edu (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: Importing C Structures Date: 24 Mar 1995 12:30:09 -0500 Organization: Courant Institute of Mathematical Sciences Message-ID: <3kuvj1$cro@gnat.cs.nyu.edu> References: <3kr4q3$jd9@newsflash.concordia.ca> NNTP-Posting-Host: gnat.cs.nyu.edu Date: 1995-03-24T12:30:09-05:00 List-Id: Vladimir writes: type A_Struct is record foo : IC.int; bar : IC.char_array (1 .. 10); q : access IC.long; end record; that's wrong, you can't use anonymous access types like this (It's always a good idea to compile code that you put on CLA, to protect against slipups like this, which can confuse the unwary). If I were doing this in GNAT, I wouldn't bother with Interfaces.C, since obviously you are not trying to write code that can be ported to other Ada 95 compilers. Instead I would just write type A_Struct is record foo : Integer; bar : String (0 .. 9); q : Access_Long_Integer; end record; it is particularly nice to avoid the To_Ada and To_C stuff for converting between GNAT Character/String and C char/char*, since these are always the same in GNAT. Interfaces.C is predicated on the assumption that Ada and C will use different data structures for basic data. THis assumption is wrong for GNAT. Of course if you want to write code that will port to other Ada 95 compilers that might make less convenient choices, then you can use Interfaces.C