comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Interfacing between Ada and C: records and structs
Date: Tue, 31 Jul 2012 19:51:56 -0700
Date: 2012-07-31T19:51:56-07:00	[thread overview]
Message-ID: <jva5kc$2rgf$1@adenine.netfront.net> (raw)
In-Reply-To: <7beb59ba-ca6f-476e-8b39-604196b0b79f@googlegroups.com>

On 07/31/2012 09:27 AM, awdorrin wrote:
> I have some legacy code that I am working with, they share common data structures.
>
> Simplifying my code, In Ada, I have a record:
>
> type FP_SHARED_BUF_TYPE is
> record
>    LOCK_SHM_1 : aliased Mutex;
>    LOCK_SHM_2 : aliased Mutex;
>    LOCK_SHM_3 : aliased Mutex;
> end record;
>
> In C:
>
> struct FP_SHARED_TYPE {
>    pthread_mutex_t LOCK_SHM_1;
>    pthread_mutex_t LOCK_SHM_2;
>    pthread_mutex_t LOCK_SHM_3;
> };
>
> When I compile the program, the Ada code defines the record as:
>
> for FP_SHARED_BUF_TYPE'Alignment use 9;
> for FP_SHARED_BUF_TYPE use record
>    LOCK_SHM_1 at

Anything you define in Ada that should match something defined in C should have 
a "pragma Convention (C, ...);".

-- 
Jeff Carter
"The time has come to act, and act fast. I'm leaving."
Blazing Saddles
36



--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---



       reply	other threads:[~2012-08-06 14:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7beb59ba-ca6f-476e-8b39-604196b0b79f@googlegroups.com>
2012-08-01  2:51 ` Jeffrey Carter [this message]
2012-07-31 16:38 Interfacing between Ada and C: records and structs awdorrin
2012-07-31 17:16 ` Niklas Holsti
2012-07-31 18:44   ` awdorrin
2012-07-31 19:08     ` awdorrin
2012-07-31 19:27       ` Simon Wright
2012-07-31 19:44         ` awdorrin
2012-07-31 20:46           ` Niklas Holsti
2012-08-01 12:16             ` awdorrin
2012-07-31 19:23     ` Simon Wright
2012-08-02  4:39     ` Shark8
2012-08-02 12:32       ` awdorrin
replies disabled

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