comp.lang.ada
 help / color / mirror / Atom feed
From: kug1977 <kug1977@web.de>
Subject: Access Type
Date: Fri, 24 Dec 2010 08:36:12 -0800 (PST)
Date: 2010-12-24T08:36:12-08:00	[thread overview]
Message-ID: <8d8e1094-d021-4456-85fb-bbb2f3911334@m7g2000vbn.googlegroups.com> (raw)

Hi,

this drives me crazy, because it makes me think that I don't get this
access concept in Ada ... hope someone can help here.

1. I've a Ada-function which use a string for calling a service, say
"open". This strings have to be LATIN1, so I've a type for this

       type t_OFW_Service_Name is array (Positive range <>) of
Character;

2. The calling Ada-function have to use a pointer to this array, to
call this function, so I use

       type t_OFW_Service_Name_Access is access t_OFW_Service_Name;

3. As this strings are all constant over the live-time of the
programm, I want them declare as a private constant like this

        open_SERVICE_NAME : aliased t_OFW_Service_Name (1 .. 5) :=
"open" & Ada.Characters.Latin_1.NUL;

4. In my Ada-function, I use record-set like this

     type Ci_Args is record
         Service                 : t_OFW_Service_Name_Access;
         Num_Of_Args        : Cell;
         Num_Of_Ret_Vals : Cell;
         Boot_Specifiers     : System.Address;
      end record;
      Arg   : Ci_Args;

    which I fill like this

    Arg.Service         := boot_Service_Name'Access;

Compilation failed with the following messages:

- object subtype must statically match designated subtype
- warning: aliased object has explicit bounds
- warning: declare without bounds (and with explicit initialization)
- warning: for use with unconstrained access

Brings me to the following questions.
- what mean this warnings and errors?
- how can I point to a constant string.
- Is there a easy to read tutorial about Pointers in Ada?

Thanks for your help.
kug1977








             reply	other threads:[~2010-12-24 16:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-24 16:36 kug1977 [this message]
2010-12-24 17:30 ` Access Type Robert A Duff
2010-12-24 20:59   ` kug1977
2010-12-24 22:06     ` Simon Wright
2010-12-27  1:50     ` Ludovic Brenta
2010-12-27 12:29       ` Simon Wright
2010-12-27 17:53         ` Ludovic Brenta
2010-12-27 18:15           ` Simon Wright
2010-12-27 20:03             ` Pascal Obry
2010-12-28 20:08               ` kug1977
2010-12-28 23:52                 ` Simon Wright
2010-12-29  8:46                   ` kug1977
2010-12-29 15:18                     ` Simon Wright
2010-12-29 15:27                       ` Ludovic Brenta
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox