* Ada Compiler Complaint ? @ 2001-08-28 3:02 Dale Pennington 2001-08-28 10:06 ` David C. Hoos, Sr. 0 siblings, 1 reply; 5+ messages in thread From: Dale Pennington @ 2001-08-28 3:02 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada Compiler Complaint ? 2001-08-28 3:02 Ada Compiler Complaint ? Dale Pennington @ 2001-08-28 10:06 ` David C. Hoos, Sr. 2001-08-28 10:32 ` Larry Kilgallen 2001-08-28 12:10 ` Dale Pennington 0 siblings, 2 replies; 5+ messages in thread From: David C. Hoos, Sr. @ 2001-08-28 10:06 UTC (permalink / raw) To: comp.lang.ada; +Cc: dalepenn 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" <dalepenn@hiwaay.net> Newsgroups: comp.lang.ada To: <comp.lang.ada@ada.eu.org> 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 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada Compiler Complaint ? 2001-08-28 10:06 ` David C. Hoos, Sr. @ 2001-08-28 10:32 ` Larry Kilgallen 2001-08-28 12:10 ` Dale Pennington 1 sibling, 0 replies; 5+ messages in thread From: Larry Kilgallen @ 2001-08-28 10:32 UTC (permalink / raw) In article <mailman.998993202.10206.comp.lang.ada@ada.eu.org>, "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes: > 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. Why would that be better? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada Compiler Complaint ? 2001-08-28 10:06 ` David C. Hoos, Sr. 2001-08-28 10:32 ` Larry Kilgallen @ 2001-08-28 12:10 ` Dale Pennington 2001-08-28 14:33 ` David C. Hoos 1 sibling, 1 reply; 5+ messages in thread From: Dale Pennington @ 2001-08-28 12:10 UTC (permalink / raw) 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 : <filetype, forgot name) 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. <david.c.hoos.sr@ada95.com> 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" <dalepenn@hiwaay.net> > Newsgroups: comp.lang.ada > To: <comp.lang.ada@ada.eu.org> > 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 > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada Compiler Complaint ? 2001-08-28 12:10 ` Dale Pennington @ 2001-08-28 14:33 ` David C. Hoos 0 siblings, 0 replies; 5+ messages in thread From: David C. Hoos @ 2001-08-28 14:33 UTC (permalink / raw) To: comp.lang.ada; +Cc: dalepenn 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" <dalepenn@hiwaay.net> Newsgroups: comp.lang.ada To: <comp.lang.ada@ada.eu.org> 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 : <filetype, forgot name) > 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. <david.c.hoos.sr@ada95.com> 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" <dalepenn@hiwaay.net> > > Newsgroups: comp.lang.ada > > To: <comp.lang.ada@ada.eu.org> > > 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 > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-08-28 14:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-08-28 3:02 Ada Compiler Complaint ? Dale Pennington 2001-08-28 10:06 ` David C. Hoos, Sr. 2001-08-28 10:32 ` Larry Kilgallen 2001-08-28 12:10 ` Dale Pennington 2001-08-28 14:33 ` David C. Hoos
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox