comp.lang.ada
 help / color / mirror / Atom feed
* Interfacing C type, unconstrained array with record
@ 2010-10-16 17:35 Ron Wills
  2010-10-16 18:36 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 13+ messages in thread
From: Ron Wills @ 2010-10-16 17:35 UTC (permalink / raw)


Hi all

I've started learning Ada and started porting some software I had in C/
C++ as a learning exercise. The software uses SDL, so I started a thin
wrapper around it. I've been very successful with it, but with the
exception of the palette structure which in C is defined as:

typedef struct {
  int ncolors;
  SDL_Color colors[]; // Actually is SDL_Color *colors but this is how
it is laid out in memory
} SDL_Palette;

In Ada I'm trying to do something like:

type SDL_Color is
  record
    r, g, b, unused : Uint8;
  end;
type SDL_Color_Array is array(Positive range <>) of Color;
type SDL_Palette is
  record
    ncolors : Integer;
    colors : SDL_Color_Array;
  end;

 Now Ada (GNAT) won't compile this because the colors component is
unconstrained, which is understandable. I've been googling for a
couple of days for a way of modeling this in Ada and still having
access to all the colors in the colors component. In other SDL
interface implementations, all I've seen is that the colors component
is made into a type of "Dummy" component and made more or less
useless. I've also been combing the reference manual, but nothing I've
noticed seems to solve this issue. I'm sure I'm not the only one that
has come across this problem and was wondering what solutions are
available.

Thanks



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-10-17 12:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-16 17:35 Interfacing C type, unconstrained array with record Ron Wills
2010-10-16 18:36 ` Dmitry A. Kazakov
2010-10-16 19:19   ` Ron Wills
2010-10-16 22:15     ` Jeffrey Carter
2010-10-17 10:20       ` Simon Wright
2010-10-17 12:38         ` Robert A Duff
2010-10-17  8:35     ` Dmitry A. Kazakov
2010-10-17 12:30       ` Robert A Duff
2010-10-16 21:41   ` Robert A Duff
2010-10-16 23:34     ` tmoran
2010-10-17  6:59     ` J-P. Rosen
2010-10-17 12:34       ` Robert A Duff
2010-10-17  7:45     ` Dmitry A. Kazakov

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