comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Importing C Structures
Date: 24 Mar 1995 12:30:09 -0500
Date: 1995-03-24T12:30:09-05:00	[thread overview]
Message-ID: <3kuvj1$cro@gnat.cs.nyu.edu> (raw)
In-Reply-To: VLADIMIR.95Mar22235527@speedy.intrepid.com

Vladimir writes:

type A_Struct is
        record
                foo : IC.int;
                bar : IC.char_array (1 .. 10);
                q : access IC.long;
        end record;

that's wrong, you can't use anonymous access types like this (It's always
a good idea to compile code that you put on CLA, to protect against
slipups like this, which can confuse the unwary).

If I were doing this in GNAT, I wouldn't bother with Interfaces.C, since
obviously you are not trying to write code that can be ported to other
Ada 95 compilers. Instead I would just write

type A_Struct is
  record
     foo : Integer;
     bar : String (0 .. 9);
     q   : Access_Long_Integer;
  end record;

it is particularly nice to avoid the To_Ada and To_C stuff for converting
between GNAT Character/String and C char/char*, since these are always
the same in GNAT. Interfaces.C is predicated on the assumption that Ada
and C will use different data structures for basic data. THis assumption
is wrong for GNAT.

Of course if you want to write code that will port to other Ada 95 compilers
that might make less convenient choices, then you can use Interfaces.C




  parent reply	other threads:[~1995-03-24 17:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-23  6:34 Importing C Structures Chris O'Regan
1995-03-23  7:55 ` Vladimir Vukicevic
1995-03-23 18:55   ` Robert S. White
1995-03-24  8:51     ` Vladimir Vukicevic
1995-03-25  9:57       ` Keith Thompson
1995-03-26 13:16         ` Larry Kilgallen, LJK Software
1995-03-27  0:00           ` Kevin F. Quinn
1995-04-07  0:00             ` Larry Kilgallen
1995-03-27 15:35           ` Theodore Dennison
1995-03-28  0:00             ` Robert Dewar
1995-03-28 11:44             ` Keith Thompson
1995-03-29  0:00               ` misattrubation (was: Re: Importing C Structures) Theodore Dennison
1995-03-31  0:00                 ` Theodore Dennison
1995-03-27 23:39           ` Importing C Structures Keith Thompson
1995-03-27 16:00       ` Norman H. Cohen
1995-03-24 16:08     ` Robert I. Eachus
1995-03-24 20:20     ` Bob Gilbert
1995-03-25 18:07     ` Robert Dewar
1995-03-24 17:30   ` Robert Dewar [this message]
1995-03-24 15:32 ` Robert Dewar
replies disabled

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