comp.lang.ada
 help / color / mirror / Atom feed
From: Jeff Carter <jrcarter010@earthlink.net>
Subject: Re: More C
Date: 2000/01/28
Date: 2000-01-28T00:00:00+00:00	[thread overview]
Message-ID: <3890ECFE.5FFAFCB3@earthlink.net> (raw)
In-Reply-To: vhizotrc4x7.fsf@grotte.ifi.uio.no

Jan Kroken wrote:
> I have the following C structs
> 
> typedef struct {
>         Uint8 r;
>         Uint8 g;
>         Uint8 b;
>         Uint8 unused;
> } SDL_Color;
> 
> typedef struct {
>         int       ncolors; /* number of colors */
>         SDL_Color *colors; /* array of colors */
> } SDL_Palette;
> 
> and have included them in Ada as
> 
> type SDL_Color is record
>         R, G, B, Unused: C.Unsigned_Char;
> end record;

Note the comment that this is an array. The best way to treat this in
Ada is probably as an array:

type SDL_Palette is record
   Num_Colors : C.Int;
   Address_Of_Color_Array : System.Address;
end record;

Given:

   Palette : SDL_Palette;

containing data from C, use

type Color_Set is array (C.Int range <>) of SDL_Color;

Colors : Color_Set (1 .. Palette.Num_Colors);
for Colors'Address use Palette.Address_Of_Color_Array;

That only answers 1 of your 2 questions, I'm afraid.

-- 
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail




  parent reply	other threads:[~2000-01-28  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <vhizotrc4x7.fsf@grotte.ifi.uio.no>
2000-01-28  0:00 ` More C tmoran
2000-01-28  0:00   ` David Starner
2000-01-28  0:00     ` Pascal Obry
2000-01-28  0:00       ` David Starner
2000-01-28  0:00         ` tmoran
2000-01-28  0:00 ` Jeff Carter [this message]
2000-01-28  0:00 ` Gautier
2000-01-30  0:00 ` Nick Roberts
     [not found]   ` <vhioga1r2j8.fsf@grotte.ifi.uio.no>
2000-02-01  0:00     ` tmoran
2000-02-02  0:00     ` Nick Roberts
2000-02-03  0:00     ` Keith Thompson
replies disabled

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