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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,63f1f8d3ec129778 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-18 15:52:42 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!uunet!lax.uu.net!sac.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Trouble translating a C expression to Ada X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3BCF5B06.7DDB57F4@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: Mime-Version: 1.0 Date: Thu, 18 Oct 2001 22:43:18 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:14923 Date: 2001-10-18T22:43:18+00:00 List-Id: file13 wrote: > > How would one translate this expression into Ada: > > raw_pixels[offset] = pixel_color; Something along the lines of type Raw_Pixel_Set is array (Some_Range) of Interfaces.Unsigned_16; Raw_Pixel : Raw_Pixel_Set; Pixel_Color : Interfaces.Unsigned_16; Offset : ...; -- Appropriate type to index a Raw_Pixel_Set ... Raw_Pixel (Offset) := Color; > > where raw_pixels is a pointer to a SDL Uint16 type (i.e. Uint16 > *raw_pixels;) > offset is an integer, and pixel_color is a SDL Uint16 type (not a pointer). > Pointers are needed much less frequently in Ada than in C, and if you're translating C to Ada you should take advantage of every opportunity to eliminate pointers in the Ada version. If every pointer in the C becomes a pointer in Ada, I see little reason for the translation. > one of it's prototypes is: > function Increment ( > Pointer : Uint16_Ptrs.Object_Pointer; > Amount : Natural) return Uint16_Ptrs.Object_Pointer; > pragma Inline (Increment); This is not a prototype. This is a function specification. -- Jeffrey Carter