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-Thread: 103376,c1da643bcd91f37b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Mon, 03 Apr 2006 20:31:42 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: Advice on low level file handling. Date: Mon, 3 Apr 2006 20:31:49 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-xuRqiZ0USNtYDJdqlsyUF1SHm8nwu8ZNv5mRLdmiRrcFQsdT5JINWX3Uwo7i3KkHrYlwb6Us7Z5fhtF!fYAV553Ym4GCwwt1VowcZbMH1nGSK2orv8erMbdpGQLyU+loSbF6dnO5oJxHFLq4gOIqsi7OzU2T X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:3715 Date: 2006-04-03T20:31:49-05:00 List-Id: "Peter C. Chapin" wrote in message news:Xns9798DDB851DB4pchapinsovernet@198.186.192.137... > > I'm working on a program that needs to read an input file on a byte by byte > basis and examine bit fields and do bitwise shifting in some of these > bytes. Other parts of the file are to be treated as uninterpreted data > (this is an OpenPGP message file). Right now I'm using Interfaces.Unsigned_ > 8 as the type to hold a single byte from the file and I'm instantiating > Ada.Sequential_IO with this type to get the necessary file reading > subprograms. So far this seems okay, but I'm wondering if this is the most > appropriate way to do this. Why aren't you using Stream_IO for this? You don't need to declare your own types for this sort of I/O. Perhaps you thought that you could only use Stream_IO with the stream attributes? Actually, I think it is more useful to use by itself, especially in the sort of case you have here. Byte at a time I/O can be painfully slow; Stream_IO lets you input a batch of stuff and then process it. >...Is that portable? I'm not extremely worried about > portability, but I'd rather not sacrifice it for no reason. A machine might not have Unsigned_8 (like the U2200, it has Unsigned_9 instead); but there is going to be a definition of Stream_Element. On the vast majority of machines, that will be an 8-bit entity. OTOH, if you *must* have an 8-bit byte, then I'd suggest declaring it yourself and using Sequential_IO as you did. > I can define a 64 bit modular type and that seems to work > fine on gnat. Is that portable? Not really, but an Ada compiler will reject the program if it doesn't work. (As someone else pointed out, many Ada compilers don't support 64-bit numbers.) But it's probably portable enough for your purposes; there isn't much point in working around the lack of 64-bit math until you actually have to work on a compiler that doesn't support it. Randy.