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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,d4984245154c8ef1,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!t8g2000yqk.googlegroups.com!not-for-mail From: Ron Wills Newsgroups: comp.lang.ada Subject: Interfacing C type, unconstrained array with record Date: Sat, 16 Oct 2010 10:35:39 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 24.89.74.35 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1287250539 11033 127.0.0.1 (16 Oct 2010 17:35:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 16 Oct 2010 17:35:39 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t8g2000yqk.googlegroups.com; posting-host=24.89.74.35; posting-account=sfUYLwoAAADgN4x5cQtEVb7ua7QwdFn4 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:15543 Date: 2010-10-16T10:35:39-07:00 List-Id: 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