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=-2.8 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, TRACKER_ID autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ed023c7889c56295 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-28 07:33:32 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!sn-xit-03!supernews.com!freenix!enst!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Ada Compiler Complaint ? Date: Tue, 28 Aug 2001 09:33:04 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 999009209 83383 137.194.161.2 (28 Aug 2001 14:33:29 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 28 Aug 2001 14:33:29 +0000 (UTC) Cc: To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:12516 Date: 2001-08-28T09:33:04-05:00 First let me apologize for misunderstanding your original post and providing an erroneous response. I was thinking you were writing binary data, when in fact you're writing text. At any rate, the following code compiles and links without error or warning on Linux with gnat 3.12p, and produces the following output: 10000010010000101100001000100010101000100110001011100010 So... from the incomplete code you supplied, and the lack of information about the compiler and the platform being used, I am unable to intuit what the problem might be. with Ada.Text_IO; with System; package X is type Bit is range 0 .. 1; for Bit'Size use 1; type Bit_Array is array (1 .. 20000) of Bit; pragma Pack (Bit_Array); type Bit_Array_Ptr is access Bit_Array; package Bit_Io is new Ada.Text_Io.Integer_Io (Bit); procedure Y (Buffer : System.Address; Size : Integer; Outfile : Ada.Text_IO.File_Type); end X; with Ada.Unchecked_Conversion; package body X is function To_Bit_Array is new Ada.Unchecked_Conversion (System.Address,Bit_Array_Ptr); procedure Y (Buffer : System.Address; Size : Integer; Outfile : Ada.Text_IO.File_Type) is A_Bit_Array : Bit_Array_Ptr; begin A_Bit_Array := To_Bit_Array (Buffer); for I in 1 .. Size * 8 loop Bit_Io.Put (Outfile, A_Bit_Array (I), 1); end loop; end Y; end X; with Ada.Text_IO; with System; with X; procedure Test_X is File : Ada.Text_IO.File_Type; Data : String := "ABCDEFG"; Buffer : System.Address := Data'Address; begin Ada.Text_IO.Create (File, Ada.Text_IO.Out_File, "x.dat"); X.Y (Buffer, Data'Length, File); end Test_X; ----- Original Message ----- From: "Dale Pennington" Newsgroups: comp.lang.ada To: Sent: Tuesday, August 28, 2001 7:10 AM Subject: Re: Ada Compiler Complaint ? > First, this is code that we are being given by a third party as a library. > Looking at the code segement it is being to used to dump a bit packed buffer > area. The procedure Y kinda looks like this (PS do not hit me on small > syntax errors, this is off the top of my head). > > function To_Bit_Array is new > Unchecked_Conversion(System.Address,Bit_Array_Ptr); > > procedure Y( buffer : System.Address ; > size : integer; > Outfile : A_Bit_Array : Bit_Array_Ptr; > I : integer; > begin > A_Bit_Array := To_Bit_Array(buffer); > > for I in 1..size*8 loop > Bit_Io.Put(Outfile,A_Bit_Array(I),1); > end loop > > ... > end Y; > > Suitability aside, I really want to know why the compiler rejects the code. > > Thanks > Dale Pennington > > David C. Hoos, Sr. wrote in message > news:mailman.998993202.10206.comp.lang.ada@ada.eu.org... > > Since file IO can only be done in whole bytes, what > > was your intention in instantiating Integer_IO for > > your Bit type? E.g., ion which bit of each byte would > > the data bit reside? > > > > Incidentally, the type bit would probably be better defined > > as mod 2 instead of range 0 .. 1. > > > > ----- Original Message ----- > > From: "Dale Pennington" > > Newsgroups: comp.lang.ada > > To: > > Sent: August 27, 2001 10:02 PM > > Subject: Ada Compiler Complaint ? > > > > > > > Folks, looks like my company news server is acting wierd, so I am also > > > posting from a home account. If this shows up twice, just ignore the > second > > > one. > > > > > > I have a chunk of code giving me an error I do not understand. The code > is : > > > > > > package X > > > ... > > > type Bit is range (0..1); > > > for Bit'Size use 1; > > > > > > type Bit_Array is array(1..20000) of Bit; > > > pragma Pack(Bit_Array); > > > > > > type Bit_Array_Ptr is access Bit_Array; > > > > > > package Bit_Io is new Ada.Text_Io.Integer_Io(Bit); > > > > > > ... > > > > > > procedure Y > > > ... > > > A_Bit_Array : Bit_Array_Ptr; > > > begin > > > ... > > > Bit_Io.Put(Outfile,A_Bit_Array(I),1); > > > ... > > > end Y; > > > ... > > > end package X; > > > > > > The compiler complains for the Bit_Io.Put instruction on the column > > > A_Bit_Array starts : > > > expected type "System.Unsigned_Types.Packed_Byte" > > > found type "Bit" defined at xxx. > > > > > > Where xxx is the line the type Bit is at. > > > > > > Anyone know why the compiler is complaining, and what I can do about it > ? > > > > > > Thanks > > > > > > Dale Pennington > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > comp.lang.ada mailing list > > > comp.lang.ada@ada.eu.org > > > http://ada.eu.org/mailman/listinfo/comp.lang.ada > > > > > > > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >