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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,627ecf5c03d8e237,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.75.8 with SMTP id y8mr1204327wiv.4.1344264971650; Mon, 06 Aug 2012 07:56:11 -0700 (PDT) Path: n2ni72830431win.0!nntp.google.com!feed-C.news.volia.net!volia.net!news2.volia.net!feed-A.news.volia.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!news.panservice.it!feeder.erje.net!news2.arglkargh.de!news.glorb.com!news.netfront.net!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Interfacing between Ada and C: records and structs Date: Tue, 31 Jul 2012 19:51:56 -0700 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: <7beb59ba-ca6f-476e-8b39-604196b0b79f@googlegroups.com> NNTP-Posting-Host: 184.20.208.96 Mime-Version: 1.0 X-Trace: adenine.netfront.net 1343789518 93711 184.20.208.96 (1 Aug 2012 02:51:58 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Wed, 1 Aug 2012 02:51:58 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 In-Reply-To: <7beb59ba-ca6f-476e-8b39-604196b0b79f@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-07-31T19:51:56-07:00 List-Id: 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 ---