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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,976a050e0f89277c X-Google-Attributes: gid103376,public From: Jonathan Guthrie Subject: Re: Urgent question: malloc and ada...READ/NEW/FOLLOWUP Date: 1998/04/26 Message-ID: <6hvm8k$t3l$1@news.hal-pc.org>#1/1 X-Deja-AN: 347835783 References: <352A79C2.15FB7483@nathan.gmd.de> <1998Apr10.073110.1@eisner> Organization: Information Broker Systems Internet Services Newsgroups: comp.lang.ada Date: 1998-04-26T00:00:00+00:00 List-Id: In comp.lang.ada Robert Dewar wrote: > This probably indicates a lack of knowledge about how Ada handles this problem > (Joe indicates later that he is not familiar with the technical details). The > approach in Ada is that the entire responsibility of correct interface is > placed on the Ada compiler system. For example, when we write: > type x is record > a : Interfaces.C.int; > b : Interfaces.C.char; > end record; > pragma Convention (C, x); > the Ada compiler is responsible for laying out the type x identically to the > corresponding C record in the particular environment in which the Ada > compiler operates. How does the Ada compiler implemetor know what C compiler is used in that "particular environment in which the compiler operates"? Telepathy? I realize that, in the case of GNAT, (you assume) that compiler is going to be GCC and that the way that code is generated by that compiler is necessarily well understood by the GNAT team, but that information simply isn't available to the implementor in the general case. In fact, for those situations where the foreign language facility is most useful (that is, you have to use a pre-built library that somebody got from somewhere) the use of the foreign language facility may require information (what compiler options/pragmas were used) that is unavailable by any means. In particular, what happens if they're using GNAT under Linux and some C compiler other than GCC that organizes things differently than GCC does? I suspect that the case isn't handled particularly well. (Don't believe that such compilers exist? Well, as it happens I feel like writing a C compiler today...B-)) Or do you have pragma's for specifying which C compiler you need to interface with? (If that's true, how do you pass the validation suite without changing the pragma?) Note that I am not claiming this to be a deficiency in the Ada language specification. I believe that the problem simply isn't solvable in the general case. (Well, it IS solvable, but the effort isn't anything like worthwhile. I would expect that you have to provide a mechanism to allow the programmer to specify the layouts of structs, arrays, and so forth. Since figuring out the way things are laid out is the hard part, why bother?) Just out of curiousity, how DO you handle "pragma pack"? Do you provide equivalent pragmas for all the possible cases? -- Jonathan Guthrie (jguthrie@brokersys.com) Information Broker Systems +281-895-8101 http://www.brokersys.com/ 12703 Veterans Memorial #106, Houston, TX 77014, USA We sell Internet access and commercial Web space. We also are general network consultants in the greater Houston area.