comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Question: Exporting ADA functions to C
Date: Wed, 21 Mar 2001 18:58:24 GMT
Date: 2001-03-21T18:58:24+00:00	[thread overview]
Message-ID: <kR6u6.428$fy.1104@www.newsranger.com> (raw)
In-Reply-To: 3AB8D3F9.FC6C6B9E@uundz.de

In article <3AB8D3F9.FC6C6B9E@uundz.de>, Tilman Gloetzner says...
>I am trying to hand over a c-struct to an ada record and vice versa. The
..
>protable. Unfortunatelly, my test progam crashes with a core dump. Not
..
>   procedure Register_Record(C_Structure: in Rec_C);
>   procedure Get_Record(C_Structure: out Rec_C);
>
>   pragma Export(C,Register_Record,"C_Register_Rec");
>   pragma Export(C,Get_Record,"C_Get_Rec");
..
>extern void adainit (void);
>extern void adafinal (void);
>extern void C_Register_Rec(struct Ada_rec Structure);
>extern void C_Get_Rec(struct Ada_rec Structure);

Ada cannot deal with C "struct" parameters. Pointer to structs are ok, but not
structs themselves. If I remember correctly, this is because C itself has no
real standard (or no universally-followed standard) on how structs are passed,
but that could be wrong.

Anyway, the proper C prototypes for your exported Ada routines would be:

extern void C_Register_Rec (struct Ada_rec * Structure);
extern void C_Get_Reg (struct Ada_rec * Structure);

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  reply	other threads:[~2001-03-21 18:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-21 16:16 Question: Exporting ADA functions to C Tilman Gloetzner
2001-03-21 18:58 ` Ted Dennison [this message]
2001-03-21 19:35   ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox