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: 103376,9208806da73239cc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!not-for-mail From: di98mase@hotmail.com (Sebastian) Newsgroups: comp.lang.ada Subject: Re: Pointers in Ada Date: 5 Mar 2005 07:47:41 -0800 Organization: http://groups.google.com Message-ID: <6acda821.0503050747.79f9544f@posting.google.com> References: <6acda821.0503040425.3b437e6a@posting.google.com> <0L1Wd.824$oO4.709@newsread3.news.pas.earthlink.net> NNTP-Posting-Host: 81.230.82.46 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1110037661 28990 127.0.0.1 (5 Mar 2005 15:47:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 5 Mar 2005 15:47:41 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:8650 Date: 2005-03-05T07:47:41-08:00 List-Id: Jeffrey Carter wrote in message news:<0L1Wd.824$oO4.709@newsread3.news.pas.earthlink.net>... > Sebastian wrote: > > > package Mdp_Lld; > > type Message_Header is > > record > > Word_Count : Byte; > > Command_Id : Byte; > > end record; > > > > subtype Mdp_Message_Data is Byte(1..500); > > > > type A_Mdp_Message is > > record > > Header : aliased Message_Header; > > Data : aliased Mdp_Message_Data; > > end record; > > > > type Driver_Msg_Ptr_Type is access all A_MDP_Message; > > > > procedure Put_Message > > (Msg_Buffer_Ptr : in out Client_Msg_Ptr_Type; > > ); > > As you're no doubt aware, this won't compile. In addition to the syntax > error in the declaration of Put_Message, Client_Msg_Ptr_Type has not > been declared. > > Before we can answer your questions, we need to know why you're using > pointers. What wrong with > > procedure Put_Message (Message : in An_Mdp_Message); > > ? > > In Ada pointers are needed far more rarely than in some other languages. > Since you're not building a dynamic data structure, it's likely that you > don't need them. If you really do need them, it's probably a better > design to hide them from the clients of the package. That way you can > localize the memory management to your package. Hi everybody thanks for your answers. First, I have not written the code myself it is a UDP/IP stack that I found as a open source. I would not use pointers myself thats why I'm havning problems knowing how to initialize them;) Anyway, sorry that the code does not compile but I extracted it from the files and "tweaked" it to fit the forum. Soo, in order to create a message and send it using Put_Message I have to create a variable of the private type Client_Msg_Ptr_Type in "my calling source code file" BUT in order to do that the calling code must be within a child package to the Mdp_lld package otherwise the private type is not visable, or am I missing something here? Also the Outmessage has to be aliased and I have to write the code like: My_Msg_Ptr := Outmessage'Access; Will this work? Well I will try it on monday...I'll let you know.. Thanks, Sebastian