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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,36c197595b07e443 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!z41g2000yqz.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: Cross-platform issues Date: Mon, 7 Dec 2009 13:05:54 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 82.30.110.254 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1260219957 8953 127.0.0.1 (7 Dec 2009 21:05:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Dec 2009 21:05:57 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z41g2000yqz.googlegroups.com; posting-host=82.30.110.254; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8339 Date: 2009-12-07T13:05:54-08:00 List-Id: On Dec 6, 11:39=A0pm, Leslie wrote: > =A0 =A0 =A0 =A0 What I'm working on is a product that I want to conform a= s > closely as possible to the one that inspired it. =A0The original > emits trace data with things like field length info in 4-byte > integers, for example. I suppose that using a derived type to > ensure that in my implementation those fields conform with the > original is one way to do it, but is that accepted practice, or > is there a more usual one? I'd start by defining the data to be sent over the net. You could base your data structures on the types in package Interfaces, then there's no worry about the size of Interfaces.C.int. Then I'd format the data to be sent using the stream attribute ('Write, most likely). The simpler your types the less likely is it that compilers will disagree about the way the data is mapped to the output stream of octets. If you're using GNAT, the package GNAT.Sockets provides stream- oriented interfaces to IP sockets. Also if you're using GNAT you can transparently convert to/from network byte order; take the file s-strxdr.adb from your compiler's Ada library (.../adainclude/), copy to your source directory, rename to s-stratt.adb, build using gnatmake -a to force local rebuild of the affected parts of the RTL.