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,fa4a527ee1c9d1e6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!newscon02.news.prodigy.com!prodigy.net!cyclone.swbell.net!bos-service1.raytheon.com!dfw-service2.ext.ray.com.POSTED!53ab2750!not-for-mail From: Jeffrey Carter User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Using fwrite in Ada References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 11 Aug 2005 14:59:35 -0700 NNTP-Posting-Host: 147.24.111.90 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.ray.com 1123797577 147.24.111.90 (Thu, 11 Aug 2005 16:59:37 CDT) NNTP-Posting-Date: Thu, 11 Aug 2005 16:59:37 CDT Organization: Raytheon Company Xref: g2news1.google.com comp.lang.ada:4091 Date: 2005-08-11T14:59:35-07:00 List-Id: tmoran@acm.org wrote: > >> cptr : chars_ptr; >> Buffer : String (1..100); >> cptr:=New_String(Buffer); > > implies that chars_ptr is an access to an unconstrained array. So it > points to both the subscript range of the string and to the character data > in the string. That is not the same thing as a C pointer to a byte (that > may happen to be the first byte in the string). No. From ARM B.3.1(22): 'The type chars_ptr is C-compatible and corresponds to the use of C's ``char *'' for a pointer to the first char in a char array terminated by nul.' > >> vptr:=voids(cptr); >> >> fwrite(vptr,100,1,stdout); >>But this won't compile, the compiler says that it cannot convert the >>chars_ptr to voids. Coming from a C background, I don't understand why >>something cannot be cast to void. > > In Ada, type matters. What would you expect to happen if you said > cptr := chars_ptr(vptr); > How would the cptr find out the size of the string that held the byte > that vptr currently points to? The problem is that Chars_Ptr is defined as type chars_ptr is private; Thus, it is not an access type, so there is no conversion to an access type defined for it. All this is an elephant, however, since there are better ways to do binary output to standard output. -- Jeffrey Carter "Now go away or I shall taunt you a second time." Monty Python and the Holy Grail E-mail: jeffrey_r_carter-nr [commercial-at] raytheon [period | full stop] com