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,747be3e35071507b X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Calling C function with structure parameter from ADA Date: 1995/04/06 Message-ID: #1/1 X-Deja-AN: 100939420 references: <3lbu1o$n3p@theopolis.orl.mmc.com> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1995-04-06T00:00:00+00:00 List-Id: T.E.D. assumes that C passes structures by address. This is wrong, it varies from one machine environment to another. The RM essenstially repeats this misconception by requiring Ada to pass a record by address for Convention C, thus, on some machines ensuring that Ada is incompatible with C. Actually this is not a requirement, it is implementation advice. It is also one of the few cases in which GNAT quite deliberately declines to follow the implementation advice in the RM. In GNAT, if you make a procedure convention C, then we pass records EXACTLY THE SAME WAY THAT C would pass them, guaranteeing compatibility with C -- This seems a much better approach, and for example, simply and directly solves the original poster's problems. I hope other compilers will make this same sensible decision. If not, watch out, your Ada compiler may go out of its way to ensure that it is incompatible with C! Note: in discussion of this point earlier on, the MRT suggested simply changing the C code to pass the structure by pointer, but that is irrelevant to the task of creating bindings to existing C interfaces, where it is essential to be able to model C exactly. I suppose we could have two conventions C C_Done_Right but that seems unnecessary :-)