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,4a2fc7666c876b8e,start X-Google-Attributes: gid103376,public From: Pascal MALAISE Subject: Interfacing C with "function F return SYSTEM.ADDRESS;" Date: 1998/06/13 Message-ID: <3582296C.8404E585@magic.fr>#1/1 X-Deja-AN: 362253922 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Organization: Magic On Line Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-06-13T00:00:00+00:00 List-Id: Hi, I'd like to interface a C function: char *f() to ada95, using gnat on Linux. (in fact f is "char *strerror(int errnum);" and returns a pointer to a static string) With gnat 3.9 I used something like type STR_ACCESS is access STRING. function F return STR_ACCESS; pragama IMPORT... It compiled and was OK With gnat 3.10p, I get warning: return type of "F" does not correspond to C pointer I try: function F return SYSTEM.ADDRESS; then a unchecked_conversion from SYSTEM.ADDRESS to STR_ACCESS I get warning: types for unchecked conversion have different sizes OK. Access to unconstrained array is not an address any more. I think I can't use C.INTERFACE.char_array type instead of STRING for similar reasons. My best solution so far is to declare a local string STR and strcpy from F result to STR'ADDRESS with function C_STRCPY (DEST, SRC : SYSTEM.ADDRESS) return SYSTEM.ADDRESS; pragma IMPORT (C, C_STRCPY, "strcpy"); then look for ASCII.NUL in STR and return the proper slice. Any nicer (more ada like) idea? Thank's in advance -- Pascal MALAISE | E-mail: 22 Avenue de CHOISY | (priv) malaise@magic.fr 75013 PARIS | (prof) malaise@fr.airsysatm.thomson-csf.com FRANCE